脚本 – 从VBScript获取Shell的结果
发布时间:2020-12-15 19:01:37 所属栏目:安全 来源:网络整理
导读:Set wshShell = WScript.CreateObject ("WSCript.shell")wshshell.run "runas ..." 如何获取结果并显示在MsgBox中 您将需要使用WshShell对象的Exec方法而不是Run.然后只需从标准流中读取命令行的输出.试试这个: Const WshFinished = 1Const WshFailed = 2st
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
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
