Board logo

标题: [文件操作] [已解决]发送到桌面快捷方式在批处理里怎么写? [打印本页]

作者: dwz    时间: 2008-10-2 03:22     标题: [已解决]发送到桌面快捷方式在批处理里怎么写?

要把常用的软件图标或者常用的文件夹发送到桌面快界方式,在批处理里该怎么写?
作者: pusofalse    时间: 2008-10-2 09:06

  1. @echo off
  2. (echo [internetshortcut]
  3. echo url="程序所在路径")>"%userprofile%\桌面\test.url"
复制代码

作者: dwz    时间: 2008-10-3 02:28

用这个方法发送的快捷方式为什么能打开目录,但是对可执行程序就无效啊
作者: raozhao2008    时间: 2008-10-3 11:55

可以啊,QQ能行
只是我要想把那图标改成企鹅,该怎么办?
作者: lzwudi    时间: 2008-10-7 00:03

用VBS才能实现所有效果:
  1. Set WshShell = WScript.CreateObject("WScript.Shell")
  2. strDesktop = WshShell.SpecialFolders("AllUsersDesktop") '在桌面创建一个快捷方式
  3. set oShellLink = WshShell.CreateShortcut(strDesktop & "\记事本.lnk") '快捷方式名称
  4. oShellLink.TargetPath = "C:\WINDOWS\NOTEPAD.EXE" '目标
  5. oShellLink.WindowStyle = 1 '参数1默认窗口激活,参数3最大化激活,参数7最小化
  6. oShellLink.Hotkey = "" '快捷键
  7. oShellLink.IconLocation = "C:\WINDOWS\NOTEPAD.EXE, 0" '图标
  8. oShellLink.Description = "" '备注
  9. oShellLink.WorkingDirectory = "C:\WINDOWS\" '起始位置
  10. oShellLink.Save '创建保存快捷方式
复制代码
如果想用批处理,给你个思路:
把上面的代码写入VBS再运行!
  1. @echo off
  2. >"%userprofile%\桌面\2.vbs" echo Set WshShell = WScript.CreateObject("WScript.Shell")
  3. >>"%userprofile%\桌面\2.vbs" echo strDesktop = WshShell.SpecialFolders("AllUsersDesktop")
  4. >>"%userprofile%\桌面\2.vbs" echo set oShellLink = WshShell.CreateShortcut(strDesktop ^& "\记事本.lnk")
  5. >>"%userprofile%\桌面\2.vbs" echo oShellLink.TargetPath = "C:\WINDOWS\NOTEPAD.EXE"
  6. >>"%userprofile%\桌面\2.vbs" echo oShellLink.WindowStyle = 1
  7. >>"%userprofile%\桌面\2.vbs" echo oShellLink.Hotkey = ""
  8. >>"%userprofile%\桌面\2.vbs" echo oShellLink.Ic
  9. >>"%userprofile%\桌面\2.vbs" echo oShellLink.Description = ""
  10. >>"%userprofile%\桌面\2.vbs" echo oShellLink.WorkingDirectory = "C:\WINDOWS\"
  11. >>"%userprofile%\桌面\2.vbs" echo oShellLink.Save
  12. call "%userprofile%\桌面\2.vbs"
  13. del/f/q "%userprofile%\桌面\2.vbs"
复制代码

[ 本帖最后由 lzwudi 于 2008-10-7 00:25 编辑 ]
作者: dwz    时间: 2008-10-7 16:19     标题: 回复 5楼 的帖子

谢谢高手大哥,非常管用!
作者: Wingl83    时间: 2008-10-12 15:58

若我想在“目标”栏中添加参数应该怎样做呢?

我尝试过了,我想添加“ /clipregedit”参数,但出来的结果是“ \clipregedit”。应该怎样解决?

[ 本帖最后由 Wingl83 于 2008-10-12 16:05 编辑 ]
作者: zqz0012005    时间: 2008-10-12 19:48     标题: 回复 7楼 的帖子

代码中加上
oShellLink.Arguments = " /clipregedit"
作者: wesbow    时间: 2008-10-13 10:53

我是这样实现的
  1. @echo off
  2. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t reg_dword /d 00000000 /f
  3. del tmp.vbs /s /q
  4. cls
  5. color 0a
  6. title 建立快捷方式
  7. :enterFileName
  8. cls
  9. echo 注意:请在路径的两端加上单引号即 "
  10. set fileName="%SystemRoot%\system32\calc.exe"
  11. if /i "%fileName%"=="" goto :enterFileName
  12. if not exist %filename% cls & echo 你输入的目录或者文件名不存在,请重新输入 & pause & goto :enterFileName
  13. cls
  14. echo 例如 c:\test\我的快捷方式.lnk
  15. echo 注意:
  16. echo       最后面的 .lnk 不能省略
  17. echo       这里的路径也要在两端加上单引号.
  18. echo       并且在路径中不能包括系统变量。
  19. echo.
  20. set  shortCutPath="C:\Documents and Settings\personal\桌面\计算器.lnk"
  21. echo Dim WshShell,Shortcut>>tmp.vbs
  22. echo Dim path,fso>>tmp.vbs
  23. echo path=%fileName%>>tmp.vbs
  24. echo Set fso=CreateObject("Scripting.FileSystemObject")>>tmp.vbs
  25. echo Set WshShell=WScript.CreateObject("WScript.Shell")>>tmp.vbs
  26. echo Set Shortcut=WshShell.CreateShortCut(%shortCutPath%)>>tmp.vbs
  27. echo Shortcut.TargetPath=path>>tmp.vbs
  28. echo Shortcut.Save>>tmp.vbs
  29. "%SystemRoot%\System32\WScript.exe" tmp.vbs
  30. del tmp.vbs /s /q
  31. cls
  32. if exist %shortCutPath% echo 快捷方式创建完毕... & exit>nul
  33. if not exist %shortCutPath% echo 快捷方式创建失败,请重新操作... & exit>nul
复制代码

作者: everest79    时间: 2008-10-16 07:59

  1. @echo off
  2. Set str=%*
  3. CALL Set str=%%str:%1=%%
  4. mshta VBScript:Execute("Set aaa=CreateObject(""WScript.Shell""):Set bbb=aaa.CreateShortcut(aaa.SpecialFolders(""Desktop"") & ""\%~n1.lnk""):bbb.TargetPath=""%~1"":bbb.Arguments=""%str%"":bbb.WorkingDirectory=""%~dp1"":bbb.Save:close")
  5. pause
复制代码
另存为crelnk.cmd
使用时crelnk "DPNX" 参数
作者: Wingl83    时间: 2008-11-7 16:42     标题: 回复 8楼 的帖子

多谢了……
作者: gkimkim    时间: 2011-4-20 09:49

目前还看不明白,先收藏,以后慢慢学习




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2