我有一种感觉,我应该可以添加一个目录到应用程序生命周期的PATH环境variables,但我不知道如何做到这一点。 是否可以添加一个参数到一个Windows快捷方式,将一个目录附加到被链接的应用程序使用的PATH的当前值?
让快捷方式执行一个批处理文件(.cmd),即
应该是这样的:
@echo off set path=%path%;C:\My Folder start "Path to my exe"
正如在这里解释: http : //www.labs64.com/blog/2012/06/set-environment-variables-in-windows-shortcut/你可以做到这一点,没有蝙蝠文件。
设定目标为例如:
C:\Windows\System32\cmd.exe /c "SET path=%path% && START /D ^"C:\Program Files (x86)\Notepad++^" notepad++.exe"
为了避免在再次关闭之前查看命令提示符,应该设置
Run: Minimized
在快捷方式选项卡上
(在Windows 7上测试)
直接链接到一个批处理文件产生一个恼人的控制台,你可能想避免。 这是一个解决方法。 更简单的解决方案是使用链接中的“启动最小化”选项,但在Windows 7上,您会看到一个瞬时控制台点亮任务栏。
的start.bat:
@echo off IF "%1" == "" GOTO Error IF "%2" == "" GOTO Error IF NOT EXIST %2 GOTO Error SET PATH=%1;%PATH% start %2 GOTO End :Error echo Problem! pause :End
快捷键目标:
MyPath = "C:\MyApp" Set shell = WScript.CreateObject("WScript.Shell") cmd = "start.bat " & MyPath & " MyApp.exe" shell.Run cmd, 0, false Set env = Nothing Set shell = Nothing