我正在使用hta,在其中,我的功能应与wshell.run一起运行命令行与wshell.run。

该行是:

C: xxxx xxx xxx.exe aaa.psl abc

(名称仅在这里 - 不在真实代码中。)

在我使用的JavaScript代码中:

function runCmd()
{
 wshShell.exec( "C:\xxxx\xxx\xxx.EXE aaa.psl abc" );
}

我遇到的错误是在xxx.exe应用程序中说 “找不到AAA.PSL文件”。

谢谢,罗特

有帮助吗?

解决方案 2

OKKKK TJ是男人! :)

我通过更换执行官来运行的帮助在您的帮助下做到了:

这是最终(和工作)代码:

function runCmd()
{
wshShell.CurrentDirectory = "G:\\xxx\\xxx";
wshShell.run( "xxx.EXE xxx.psl abc" ); 
}

其他提示

我很惊讶XXX.EXE程序完全运行。您需要在命令中逃脱那些后斜线:

wshShell.Exec( "C:\\xxxx\\xxx\\xxx.EXE aaa.psl abc" );
//                ^-----^----^--- here

如果您在 aaa.psl 文件名,这是您的问题。

如果您不经过通往 aaa.psl 文件,那么大多数程序(并非全部)都会期望它在 当前目录, ,因此您需要确保正确设置当前目录(尽管使用绝对路径可能是更好的选择)。

例如,这是告诉记事本编辑文件的示例:

shell = WScript.CreateObject("WScript.Shell");
shell.Exec("c:\\windows\\system32\\notepad.exe c:\\temp\\temp.txt");

...或通过当前目录:

shell = WScript.CreateObject("WScript.Shell");
shell.CurrentDirectory = "c:\\temp";
shell.Exec("c:\\windows\\system32\\notepad.exe temp.txt");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top