加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

脚本 – 从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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读