JavaScript

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

JavaScript

Post by armsys » Wed Feb 13, 2013 4:50 pm

The following script fails to run:
Run>C:\Windows\System32\wscript //B C:\ArmSys\AmiBroker\JS\test.js

On the other hand, double-clicking test.js runs successfully!
What's wrong with my MS script?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Feb 13, 2013 5:12 pm

Without researching I don't know about the wscript arguments but I would just do:

ExecuteFile>c:\ArmSys\AmiBroker\JS\test.js
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Thu Feb 14, 2013 3:01 am

What about
Run>cmd /c wscript C:\ArmSys\AmiBroker\JS\test.js
FIREFIGHTER

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Feb 14, 2013 3:27 am

CyberCitizen wrote:What about
Run>cmd /c wscript C:\ArmSys\AmiBroker\JS\test.js
Hi CyberCitizen,
Thanks for your help. Before posting my question, I have already attempted the following commands in vain. None works.
Run>C:\Windows\System32\wscript.exe C:\ArmSys\AmiBroker\JS\test.js
Run>C:\Windows\System32\cscript.exe C:\ArmSys\AmiBroker\JS\test.js
Run>cmd /C wscript c:\ArmSys\AmiBroker\JS\test.js
Run>cmd /nologo /C cscript C:\ArmSys\AmiBroker\JS\test.js
ExecuteFile>C:\ArmSys\AmiBroker\JS\test.js

On the other hand, double-click test.js, it runs brilliantly (in Windows Explorer). Or in the Cmd mode, type "test" and press enter. It works without any glitch.

However, I also discover a .bat file won't work either.
test.bat:
c:C:\ArmSys\AmiBroker\JS\test.js

So it may not be solely a Macro Scheduler problem.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Feb 14, 2013 3:52 am

After inserting some dummy message popup:
WshShell = new ActiveXObject( "WScript.Shell" );
WshShell.Popup ("NewA problem", 3,"Active X problem",0);

I found my JavaScript in question was in fact working. But some JS commands inside the JavaScript won't run when called by a Macro Scheduler script.
So, it is no longer a problem of Macro Scheduler.
Thanks for your help.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Feb 14, 2013 9:45 am

Eventually I discover the definitive solution after experimenting various scripts for the last 2 days. It turns out, by default, on the Win 7 x64 platform, the .js will trigger the 64-bit version of WScript.exe and it fails to run some, though not all, JavaScript commands.

The following command should save you many hours:
Run>%SYS_NATIVE%\WScript.exe C:\ArmSys\AmiBroker\JS\test.js

Thanks Marcus and CyberCitizen for your help.
Happy Chinese Year of the Snake!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts