从一个批处理文件创建一个exe的快捷方式 [英] creating a shortcut for a exe from a batch file

查看:277
本文介绍了从一个批处理文件创建一个exe的快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个快捷方式从批处理文件一个exe。

how to create a shortcut for a exe from a batch file.

我试图

call link.bat "c:\program Files\App1\program1.exe" "C:\Documents and Settings\%USERNAME%\Desktop" "C:\Documents and Settings\%USERNAME%\Start Menu\Programs" "Program1 shortcut"

但它并没有奏效。

but it did not worked.

link.bat可以在这里找到
<一href=\"http://www.robvanderwoude.com/amb_shortcuts.html\">http://www.robvanderwoude.com/amb_shortcuts.html

link.bat can be found at http://www.robvanderwoude.com/amb_shortcuts.html

推荐答案

您链接指向Windows 95/98的版本,我猜你至少有Windows 2000或XP。你应该在这里尝试NT版本

Your link points to a Windows 95/98 version and I guess you have at least Windows 2000 or XP. You should try the NT version here.

或者使用一个小的VBScript可以从命令行调用:

Alternatively use a little VBScript that you can call from the command line:

set objWSHShell = CreateObject("WScript.Shell")
set objFso = CreateObject("Scripting.FileSystemObject")

' command line arguments
' TODO: error checking
sShortcut = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(0))
sTargetPath = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(1))
sWorkingDirectory = objFso.GetAbsolutePathName(sShortcut)

set objSC = objWSHShell.CreateShortcut(sShortcut) 

objSC.TargetPath = sTargetPath
objSC.WorkingDirectory = sWorkingDirectory

objSC.Save

将文件另存为createLink.vbs并调用它像这样得到你最初尝试:

Save the file as createLink.vbs and call it like this to get what you originally tried:

cscript createLink.vbs "C:\Documents and Settings\%USERNAME%\Desktop\Program1 shortcut.lnk" "c:\program Files\App1\program1.exe" 
cscript createLink.vbs "C:\Documents and Settings\%USERNAME%\Start Menu\Programs\Program1 shortcut.lnk" "c:\program Files\App1\program1.exe" 

不过我劝你不要使用像开始菜单,因为它们是在Windows的本地化版本不同的硬盘codeD路径。修改脚本,而不是使用<一个href=\"http://gallery.technet.microsoft.com/ScriptCenter/en-us/0b3c068c-c765-4880-bc68-effb2d0e543e\">special文件夹的。

这篇关于从一个批处理文件创建一个exe的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆