Tutorial :problem running start..run..wscript a.vbs a.bat


I have these 2 files a.vbs and a.bat each has only one line.


CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False  


copy c:\blah\y.y c:\  

When it works, it runs a.bat quietly in the background, which does the file copy.

I can do start..run...a.vbs a.bat That works. I can open a command prompt and do wscript a.vbs a.bat

But the thing that doesn't work, is this

start...run...wscript a.vbs a.bat

if I put an msgbox in a.vbs, it's clear that runs. But it looks like a.bat doesn't run when using that method..

Howcome that form doesn't work?


When WScript.Arguments(0) is not a full path, a.bat needs to be in the current directory.

You can check the current directory with:

WScript.Echo WScript.CreateObject("WScript.Shell").CurrentDirectory  

If a.bat is always in the same folder as a.vbs, you can use a full path:

set fso=WScript.CreateObject("Scripting.FileSystemObject")  thepath=fso.BuildPath(fso.GetParentFolderName(WScript.ScriptFullName),"a.bat")  WScript.Echo thepath  


Why are you using a vbscript just to call a .bat? Start --> Run --> a.bat

If you have to do it that way, do Start --> Run --> cscript a.vbs a.bat

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »