我通常是一个 Linux 人,但我需要在 Windows 上编写一个批处理脚本来更改一些快捷方式的目标。有没有命令可以做到这一点?
Mark A. Nicolosi
问问题
58423 次
2 回答
24
我怀疑有没有办法用批处理脚本来做到这一点。不过,它在 VBScript 中是可行的。
Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut("C:\Wherever\Shortcut.lnk")
shortcut.TargetPath = "C:\Wherever\Whatever.txt"
shortcut.Save
将脚本保存在以 vbs 结尾的文件中,并使用cscript whatever.vbs
.
(不要被名称所迷惑——CreateShortcut
它既用于创建快捷方式,也用于修改快捷方式。)
于 2009-01-06T15:46:36.613 回答
7
没有 Windows 附带的本机程序来实现这一点。不久前,我在互联网上搜索了相同的功能,偶然发现了免费软件XXMKLINK。
使用 XXMKLINK,您可以编写一个批处理文件,用于由专门的安装程序完成的软件安装。基本上,XXMKLINK 是从命令行收集信息并将其打包成快捷方式。
XXMKLINK的命令语法:
xxmklink spath opath [ arg [ wdir [ desc [ mode [ icon[:n] ]]]]] where spath path of the shortcut (.lnk added as needed) opath path of the object represented by the shortcut arg argument string (use quotes with space, see below) wdir path of the working directory (for "Start in") desc description string (shown in Shosrtcut's Properties) mode display mode (1:Normal [default], 3:Maximized, 7:Minimized) icon[:n] icon file [with optional icon index value n] In addition to the above, the following switches are supported which can be placed in any position in the command line. /p prompts before action /q no output when successful (quiet) /e checks error condition strictly
缺点是您需要使用批处理脚本将 xxmklink exe 复制到每台计算机上。
链接页面底部有一个下载链接。
于 2009-01-06T15:52:34.370 回答