首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >wshell.run的返回值

wshell.run的返回值
EN

Stack Overflow用户
提问于 2014-09-09 07:11:24
回答 1查看 4.3K关注 0票数 3

我有一个VB脚本,它通过BAT文件从工具中触发作业,并获得错误/成功状态。代码为:

代码语言:javascript
运行
复制
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

如果一个作业被触发并且完成/失败,上面的代码工作正常。但是,如果作业也没有触发(启动),则表示成功。

如果作业未启动,请建议在上面的代码中可以更改/添加哪些内容。要处理的错误代码是什么。

先谢谢你...

EN

回答 1

Stack Overflow用户

发布于 2014-09-09 07:20:53

不确定这是否是你要找的。但它包含一个catch all Else语句,该语句将捕获来自WShell.Run的返回值不是1、2或3的任何实例。

如果bWaitOnReturn设置为TRUE (在本例中就是如此),则Run方法将返回应用程序返回的任何错误代码。所以无论strBATFile返回什么,WShell.Run都会返回到intReturn中。

代码语言:javascript
运行
复制
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
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25734435

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档