Command line Shell与cmd.exe-WorkingDir的区别?
我有一个启动应用程序的ActiveX脚本Command line Shell与cmd.exe-WorkingDir的区别?,command-line,cmd,activex,wsh,working-directory,Command Line,Cmd,Activex,Wsh,Working Directory,我有一个启动应用程序的ActiveX脚本 var shell = new ActiveXObject("WScript.Shell"); shell.run('appli.exe'); start appli.exe 剧本写得很好。然而,如果我打开cmd.exe并键入appli.exe我会得到一个错误,即这是一个未知命令 Appli.exe位于C:\Programs中。。。而shell.CurrentDirectory提供了C:\Users\ABC\Desktop。所以WorkingDir
var shell = new ActiveXObject("WScript.Shell");
shell.run('appli.exe');
start appli.exe
剧本写得很好。然而,如果我打开cmd.exe并键入appli.exe
我会得到一个错误,即这是一个未知命令
Appli.exe位于C:\Programs中。。。而shell.CurrentDirectory提供了C:\Users\ABC\Desktop
。所以WorkingDir不能作为答案,为什么它可以在WScript.Shell中工作,为什么它不能在CMD中工作
那么WScript.Shell如何找到Appli.exe的路径,为什么cmd.exe无法找到它呢?在windows中启动进程有几种方法。
WScript.Shell
对象的Run
方法使用ShellExecute
(或其变体为ShellExecuteEx
)。此windows API函数使用与ex.CreateProcess
(通过命令行直接调用应用程序)不同的标准来定位应用程序
这两个API函数之间的区别之一是它们查找应用程序的位置
搜索当前active directory、父进程当前active directory、windows系统目录和路径中包含的目录
(或)注册表项的内容
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
HKEY_CLASSES_ROOT\Applications
您可以使用命令行中的start
命令复制相同的行为来启动应用程序
var shell = new ActiveXObject("WScript.Shell");
shell.run('appli.exe');
start appli.exe
对与命令提示符下的
ShellExecuteEx
函数(从命令提示符下的run('appli.exe')
和start”“appli.exe
)不同,(从命令提示符下的appli.exe
)不搜索由App path
注册表项指定的每个应用程序路径。@JosefZ,这是我试图公开的内容。看来我还不够清楚。改变。