VBscript code to capture stdout, without showing console window

前端 未结 7 632
生来不讨喜
生来不讨喜 2020-11-28 11:48

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

7条回答
  •  臣服心动
    2020-11-28 12:28

    This is the way you can get the command line StdOut (result) without see this popup black dos windows in vbscript:

    Set Sh = CreateObject("WScript.Shell")
    tFile=Sh.ExpandEnvironmentStrings("%Temp%")&"\t.txt"
    Sh.Run "cmd.exe /c xcopy /? > """&tFile&""" ",0,False
    Wscript.echo CreateObject("Scripting.FileSystemObject").openTextFile(tFile).readAll()
    

提交回复
热议问题