用于捕获标准输出的 VBscript 代码,而不显示控制台窗口 [英] VBscript code to capture stdout, without showing console window

查看:23
本文介绍了用于捕获标准输出的 VBscript 代码,而不显示控制台窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个 VBScript 代码示例,展示了如何捕获命令行程序发送到标准输出的任何内容.它执行命令 xcopy/? 并在消息框中显示输出.在消息框出现之前,您会在一瞬间看到控制台窗口弹出.

This is a VBScript code example that shows how to catch whatever a command line program sends to standard output. It executes the command xcopy /? and shows the output in a message box. Before the message box appears, for a split second you see the console window popping up.

Set objShell = WScript.CreateObject("WScript.Shell")
Set objExec = objShell.Exec("xcopy /?")
Do
    line = objExec.StdOut.ReadLine()
    s = s & line & vbcrlf
Loop While Not objExec.Stdout.atEndOfStream
WScript.Echo s

这是另一个 VBScript 代码示例,展示了如何在不显示控制台窗口的情况下执行脚本.

Here is an other VBScript code example that shows how to execute a script without showing the console window.

objShell.Run "c:	empmybatch.bat C:WINDOWSsystem32cmd.exe", 0

objShell.Run "c:	empmyscript.vbs C:WINDOWSsystem32cscript.exe", 0

如您所见,它的形式为

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆