[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文件操作] [已解决]发送到桌面快捷方式在批处理里怎么写?

要把常用的软件图标或者常用的文件夹发送到桌面快界方式,在批处理里该怎么写?

  1. @echo off
  2. (echo [internetshortcut]
  3. echo url="程序所在路径")>"%userprofile%\桌面\test.url"
复制代码
心绪平和,眼藏静谧。

TOP

用这个方法发送的快捷方式为什么能打开目录,但是对可执行程序就无效啊

TOP

可以啊,QQ能行
只是我要想把那图标改成企鹅,该怎么办?

TOP

用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 编辑 ]
帮助别人是快乐
被人帮助是幸福

TOP

回复 5楼 的帖子

谢谢高手大哥,非常管用!

TOP

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

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

[ 本帖最后由 Wingl83 于 2008-10-12 16:05 编辑 ]
我是小菜菜……

TOP

回复 7楼 的帖子

代码中加上
oShellLink.Arguments = " /clipregedit"
命令行参考:hh.exe ntcmds.chm::/ntcmds.htm
求助者请拿出诚心,别人才愿意奉献热心!
把查看手册形成条件反射!

TOP

我是这样实现的
  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
复制代码

TOP

  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" 参数

TOP

回复 8楼 的帖子

多谢了……
我是小菜菜……

TOP

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

TOP

返回列表