error level checking in a vbscript

Accidental Hyper-V Administrator
Accidental Hyper-V Administrator used Ask the Experts™
on
Hello all,

I have a .vbs script that launches a DOS application which,  the writer of the application tells me,  sets errorlevel to 0 if it runs sucessfully and a 1 in not run sucessfully.

My goal is to find a snippet of vbscript which checks for the value of errorlevel and then does something based on the value.


I am launching the dos based applicaion from my .vbs script using the following lines .....

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run <the location and name of the dos executable goes here>, 1, True


I'm pretty new to vbscript so,  "simple is greatly appreciated".

Thanks in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
Commented:
How about...

Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("InsertFullPathToYourExeInHere")

Do While oExec.Status = 0
   WScript.Sleep 100
Loop

Select Case oExec.ExitCode
   Case 0
      ' do something...
           
   Case 1
      ' do something else...
           
End Select
Perfect.

Thanks a million. (Or at least 500)

:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial