我有一个VB脚本,它通过BAT文件从工具中触发作业,并获得错误/成功状态。代码为:
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如果一个作业被触发并且完成/失败,上面的代码工作正常。但是,如果作业也没有触发(启动),则表示成功。
如果作业未启动,请建议在上面的代码中可以更改/添加哪些内容。要处理的错误代码是什么。
先谢谢你...
发布于 2014-09-09 07:20:53
不确定这是否是你要找的。但它包含一个catch all Else语句,该语句将捕获来自WShell.Run的返回值不是1、2或3的任何实例。
如果bWaitOnReturn设置为TRUE (在本例中就是如此),则Run方法将返回应用程序返回的任何错误代码。所以无论strBATFile返回什么,WShell.Run都会返回到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 Ifhttps://stackoverflow.com/questions/25734435
复制相似问题