user2717144
user2717144

Reputation: 43

Return value for wshell.run

I have a VB Script which triggers the jobs from the tool through a BAT file and get the status error/success. code is :

intReturn = WShell.Run(strBATFile,0,True)

If intReturn = 1 Then 
    intReturn = 0  
    strJobStat = "Complete"
End If

If intReturn = 3 or intReturn=2 Then 
   intReturn = 1  
   strJobStat = "Error"
End If

The above code is working fine, if a job triggers and Completed/Failed. But if the job didn't trigger (started) also, it shows success.

please suggest what can be changed/added in the above code if the job did not started. What is the error code to handle.

Thanks in Advance...

Upvotes: 3

Views: 7077

Answers (1)

Donal
Donal

Reputation: 32713

Not sure if this is what you are looking for. But it contains a catch all Else statement that will capture any instances where the return value from WShell.Run is not 1, 2 or 3.

If bWaitOnReturn is set to TRUE - which it is in your case - the Run method returns any error code returned by the application. So whatever strBATFile returns will be returned by WShell.Run into intReturn.

intReturn = WShell.Run(strBATFile,0,True)

If intReturn = 1 Then 
    intReturn = 0  
    strJobStat = "Complete"
Else If intReturn = 3 or intReturn=2 Then 
   intReturn = 1  
   strJobStat = "Error"
Else
   strJobStat = "Unexpected Error"
End If

Upvotes: 3

Related Questions