Video Screencast Help

VBScript fails to execute when called from within WiseScript

Created: 24 Apr 2013 • Updated: 02 May 2013 | 5 comments
This issue has been solved. See solution.


I am trying to call a .CMD file from within a vbscript. Following is the code.

Dim WshShell, strPathName, cmdFileName
Set WshShell = CreateObject("WScript.Shell")
strPathName = Left (wscript.ScriptFullName,Instrrev (wscript.ScriptFullName,"\"))
cmdFileName = strPathName & "silentclient.cmd"
WshShell.RUN cmdFileName,0
Set WshShell = Nothing
Note : the vbscript and the .CMD file reside at the same location.
Now, when I execute the vbscript by double-clicking on it, the .CMD file gets executed as expected.
However, when I call the vbscript from within a wise script using the "Execute program" command to call %SYS32%\wscript.exe (or cscript.exe), and pass the full path of the vbs file as the command line argument, the WshShell.RUN cmdFileName,0  line does not get executed and the script exits without any error prompts.
Please help..!!
Thanks in advance.
Operating Systems:

Comments 5 CommentsJump to latest comment

VBScab's picture

Er...not that I'm a fan of it but why not just run the CMD in a WiseScript? And why not duplicate what the CMD does in the script? You have a bit of the old "elephant juggling while balancing on a beach ball" scenario going on here...

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using before posting.

EdT's picture

So you understand about calling wscript.exe and passing it a VBS file as an argument, but forget that you need to do the same with a CMD file when in a script.

VBScab is correct in his assessment that you are trying to get into your house by digging a tunnel from the garden instead of just opening the front door with your key.

To run a CMD file directly from Wisescript, use the Execute Program command, with %SYS32%\cmd.exe as the executable and /c <path to cmd file> as the argument.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

RayOfLight's picture

VBScab and EdT,

Thanks for all your valuable insights and comments.

However, I am aware that what I am doing with the VBScript can also be done with the CMD file, which is to run the CMD file from Wisescript using the Execute Program command, with %SYS32%\cmd.exe as the executable and /c <path to cmd file> as the argument.

I had tried this method, but experienced the same issue as the vbscript. The .CMD file gets executed as expected by directly double-clickng on it but exits without any error messages when called from within a wise script.

Apologies for having missed out on detailing this previously.

Anyways, after having tried out a lot of things, I finally found the resolution to the issue. A very silly miss-out that I had completely overlooked previously.

In the 'Execute Program Settings' dialog, I had set the 'Default Directory' to either %SYS32% OR simply left it BLANK which was the only cause for this issue.

Setting the 'Default Directory' to <path to cmd/vbs file> resolved the issue.

VBScab's picture

BTW, it was probably not the smartest move to use your email address as your psuedonym in a publicly-accessible forum...

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using before posting.

RayOfLight's picture

Yes thats right. Thanks for pointing it out. Will rectify that ASAP.