|
-
May 10th, 2009, 12:24 AM
#1
Thread Starter
Addicted Member
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!
-
May 10th, 2009, 01:43 AM
#2
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 10th, 2009, 03:16 AM
#3
Re: How to get exit code when running cmd command?
The WshScriptExec object returned by the Exec method has an ExitCode property.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|