脚本 – 从VBScript获取Shell的结果

前端之家收集整理的这篇文章主要介绍了脚本 – 从VBScript获取Shell的结果前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "runas ..."

如何获取结果并显示在MsgBox

您将需要使用WshShell对象的Exec方法而不是Run.然后只需从标准流中读取命令行的输出.试试这个:
Const WshFinished = 1
Const WshFailed = 2
strCommand = "ping.exe 127.0.0.1"

Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec(strCommand)

Select Case WshShellExec.Status
   Case WshFinished
       strOutput = WshShellExec.StdOut.ReadAll
   Case WshFailed
       strOutput = WshShellExec.StdErr.ReadAll
End Select

WScript.StdOut.Write strOutput  'write results to the command line
WScript.Echo strOutput          'write results to default output
MsgBox strOutput                'write results in a message Box
原文链接:https://www.f2er.com/bash/387088.html

猜你在找的Bash相关文章