windows - VBS WScript fails to execute -
i having issues getting run (or exec) methods work vbs. have been having difficulty getting arbitrary command run have resorted putting command in batch file , trying use run call .bat file. method isn't working. code follows:
dim objshell set objshell = createobject("wscript.shell") objshell.run "c:\path\to\my\batch.bat" set objshell = nothing
opening command prompt , entering 'c:\path\to\my\batch.bat' runs expect to. when using vbs code above, nothing @ all. command in batch file straight forward consisting of path executable , path file executable act on. changing run command above follows results in same thing trying call batch file - nothing @ all.
objshell.run "c:\path\to\my\executable.exe c:\path\to\my\file.extension"
my ultimate goal build path file string within script, seems irrelevant when hardcoding fails. appreciated.
i able resolve 2 changes. first, added "cmd /c" front of command.
this resulted in getting different error (file not found) , being caused timing issues program trying execute. adding 1 second delay after run command (before disposing objsehll object) resolved issue.
thanks responded.
Comments
Post a Comment