hta - Javascript wshell.run not working properly - Stack Overflow

I'm using HTA and in it I have a function that should run a mand line with wshell.run , If I'

I'm using HTA and in it I have a function that should run a mand line with wshell.run , If I'm writing this line in Windows 'Run' util it is working fine, I want it to work also in the HTA with wshell.run.

The line is:

C:\xxxx\xxx\xxx.EXE aaa.psl abc

( The names are xxx just in here - not in the real code.. )

In the javascript code I'm using:

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

The error I got is in the xxx.EXE application says "couldn't open aaa.psl File not found".

Thanks, Rotem

I'm using HTA and in it I have a function that should run a mand line with wshell.run , If I'm writing this line in Windows 'Run' util it is working fine, I want it to work also in the HTA with wshell.run.

The line is:

C:\xxxx\xxx\xxx.EXE aaa.psl abc

( The names are xxx just in here - not in the real code.. )

In the javascript code I'm using:

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

The error I got is in the xxx.EXE application says "couldn't open aaa.psl File not found".

Thanks, Rotem

Share Improve this question edited Dec 22, 2010 at 10:35 Andy E 345k86 gold badges481 silver badges451 bronze badges asked Dec 22, 2010 at 10:17 RotemRotem 4421 gold badge8 silver badges24 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

I'm surprised the xxx.EXE program is running at all. You need to escape those backslashes in the mand:

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

If you're doing the same thing in the aaa.psl filename, that's your problem.

If you're not passing a full path to the aaa.psl file, then most programs (not all) will expect it to be in the current directory, so you'll want to make sure you've set the current directory correctly (although using absolute paths may be a better option).

Here's an example, for instance, of telling Notepad to edit a file:

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

...or via the current directory:

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

Okkkk T.J. is the man!! :)

I finnaly made it with your help by replacing exec to run:

This is the final (and working) code:

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745306276a4621728.html

相关推荐

  • hta - Javascript wshell.run not working properly - Stack Overflow

    I'm using HTA and in it I have a function that should run a mand line with wshell.run , If I'

    10小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信