Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


error level checking in a vbscript

Posted on 2006-04-21
Medium Priority
Last Modified: 2008-01-09
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.
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 16509047
How about...

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

Set oExec = WshShell.Exec("InsertFullPathToYourExeInHere")

Do While oExec.Status = 0
   WScript.Sleep 100

Select Case oExec.ExitCode
   Case 0
      ' do something...
   Case 1
      ' do something else...
End Select
ID: 16509576

Thanks a million. (Or at least 500)


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Loops Section Overview

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question