这个
.Run()
方法无法读取您使用的任务的标准输出
.Exec()
为此,您需要进行一些更改来模拟
.运行()
自动为您执行。
Dim WshShell, sEXE, cmd, result
Set WshShell = CreateObject("WScript.Shell")
sEXE = """\\uncpath\file.exe"""
With CreateObject("WScript.Shell")
Set cmd = .Exec(sEXE)
'Block until complete.
Do While cmd.Status <> 1
WScript.Sleep 100
Loop
'Get output
result = cmd.StdOut.Readall()
'Check the output
WScript.Echo result
Set cmd = Nothing
End With
另一种方法是在
sEXE
变量,因此您正在使用
cmd /c
(作为
>>
命令是其中的一部分)
.
这应该管用
sEXE = "cmd /c ""\\uncpath\file.exe >> \\uncpath\%computername%.txt"""
With CreateObject("WScript.Shell")
.Run sEXE & " ", 1, true ' Wait for finish or False to not wait
End With
有用的链接