如何用批处理来创建快捷方式?
先建好一批处理文件,随同我的一个应用程序(名为:工程管理.EXE)放在同一文件夹,这个应用程序放在什么盘不定(随个人所好),当此应用程序放好后(如E盘),我就是要求运行此...
先建好一批处理文件,随同我的一个应用程序(名为:工程管理.EXE)放在同一文件夹,这个应用程序放在什么盘不定(随个人所好),当此应用程序放好后(如E盘),我就是要求运行此批处理文件,为“工程管理.EXE”建一个快捷方式到桌面,改名为“工程预算”。这个批处理文件如何写?同路径下还有一图标名为GCYS.ICO,所建的桌面的快捷方式图标就用名为GCYS.ICO的图标。
展开
3个回答
展开全部
建快捷方式注意不要被防火墙阻止了
@echo off&color f1
set lnk="%USERPROFILE%\桌面\工程预算.lnk"
set fn="%~dp0工程管理.exe"
set ico="%~dp0GCYS.ICO"
echo Dim WshShell,Shortcut>tmpe.vbs
echo Dim path,fso>>temp.vbs
echo path=%fn%>>temp.vbs
echo Set fso=CreateObject("Scripting.FileSystemObject")>>temp.vbs
echo Set WshShell=WScript.CreateObject("WScript.Shell")>>temp.vbs
echo Set Shortcut=WshShell.CreateShortCut(%lnk%)>>temp.vbs
echo Shortcut.IconLocation=%ico%>>temp.vbs
echo Shortcut.TargetPath=path>>temp.vbs
echo Shortcut.Save>>temp.vbs
temp.vbs
del temp.vbs
@echo off&color f1
set lnk="%USERPROFILE%\桌面\工程预算.lnk"
set fn="%~dp0工程管理.exe"
set ico="%~dp0GCYS.ICO"
echo Dim WshShell,Shortcut>tmpe.vbs
echo Dim path,fso>>temp.vbs
echo path=%fn%>>temp.vbs
echo Set fso=CreateObject("Scripting.FileSystemObject")>>temp.vbs
echo Set WshShell=WScript.CreateObject("WScript.Shell")>>temp.vbs
echo Set Shortcut=WshShell.CreateShortCut(%lnk%)>>temp.vbs
echo Shortcut.IconLocation=%ico%>>temp.vbs
echo Shortcut.TargetPath=path>>temp.vbs
echo Shortcut.Save>>temp.vbs
temp.vbs
del temp.vbs
展开全部
用批处理也是间接通过VBS实现,所以我直接给出VBS代码
以下在桌面生成百度的快捷方式
---------------------------------------------
set ws = createobject("wscript.shell")
strDesktop = ws.SpecialFolders("Desktop")
set wind = ws.createshortcut(strDesktop & "\baidu.lnk")
wind.targetpath = "%ProgramFiles%\Internet Explorer\IEXPLORE.EXE"
wind.workingdirectory = "%ProgramFiles%\Internet Explorer"
wind.Arguments=""
wind.save
类似的,楼主需要的就是:
set ws = createobject("wscript.shell")
strDesktop = ws.SpecialFolders("Desktop")
set wind = ws.createshortcut(strDesktop & "\1asf.lnk")
wind.targetpath = "C:\Program Files\Windows Media Player\wmplayer.exe"
wind.workingdirectory = "C:\Program Files\Windows Media Player"
wind.Arguments=""
wind.save
-------------------------------------------------
要改生成的快捷方式名称,可以对上面代码中的lasf.lnk进行修改,如
set wind = ws.createshortcut(strDesktop & "\1asf.lnk")
改成
set wind = ws.createshortcut(strDesktop & "\new.lnk")
---------------------------------------------------
如要改成批处理的,如下(我这里360会干涉,取消阻止即可)
@echo off
more %0 +5>yst.vbs
yst.vbs
del yst.vbs
exit
set ws = createobject("wscript.shell")
strDesktop = ws.SpecialFolders("Desktop")
set wind = ws.createshortcut(strDesktop & "\1asf.lnk")
wind.targetpath = "C:\Program Files\Windows Media Player\wmplayer.exe"
wind.workingdirectory = "C:\Program Files\Windows Media Player"
wind.Arguments=""
wind.save
以下在桌面生成百度的快捷方式
---------------------------------------------
set ws = createobject("wscript.shell")
strDesktop = ws.SpecialFolders("Desktop")
set wind = ws.createshortcut(strDesktop & "\baidu.lnk")
wind.targetpath = "%ProgramFiles%\Internet Explorer\IEXPLORE.EXE"
wind.workingdirectory = "%ProgramFiles%\Internet Explorer"
wind.Arguments=""
wind.save
类似的,楼主需要的就是:
set ws = createobject("wscript.shell")
strDesktop = ws.SpecialFolders("Desktop")
set wind = ws.createshortcut(strDesktop & "\1asf.lnk")
wind.targetpath = "C:\Program Files\Windows Media Player\wmplayer.exe"
wind.workingdirectory = "C:\Program Files\Windows Media Player"
wind.Arguments=""
wind.save
-------------------------------------------------
要改生成的快捷方式名称,可以对上面代码中的lasf.lnk进行修改,如
set wind = ws.createshortcut(strDesktop & "\1asf.lnk")
改成
set wind = ws.createshortcut(strDesktop & "\new.lnk")
---------------------------------------------------
如要改成批处理的,如下(我这里360会干涉,取消阻止即可)
@echo off
more %0 +5>yst.vbs
yst.vbs
del yst.vbs
exit
set ws = createobject("wscript.shell")
strDesktop = ws.SpecialFolders("Desktop")
set wind = ws.createshortcut(strDesktop & "\1asf.lnk")
wind.targetpath = "C:\Program Files\Windows Media Player\wmplayer.exe"
wind.workingdirectory = "C:\Program Files\Windows Media Player"
wind.Arguments=""
wind.save
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
学习一下,楼上两位...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询