How to get exit code when running cmd command?
Hi all,
I'm using the following way to run a script from within my VB6 app:
Code:
With CreateObject("wscript.shell")
AllocConsole
ShowWindow GetConsoleWindow, SW_HIDE
commandExec = "cmd /c myscript"
With .exec(commandExec)
line = .stdout.readall
end with
"myscript" can be a batch or a Perl script. It returns exit code. How can I read this exit code from within my app?
Thanks in advance!
Re: How to get exit code when running cmd command?
is this what you are looking for
vb Code:
Set s = CreateObject("wscript.shell")
Set s = s.exec("ping www.google.com")
Line = s.stdout.readall
Re: How to get exit code when running cmd command?
The WshScriptExec object returned by the Exec method has an ExitCode property.