输出未记录到文件 Windows shell

Output not logged to file in Windows shell

当运行宁

"C:\Program Files (x86)-Zipz.exe" a c:\Temp\Test.zip c:\Intel\* >c:\Temp\Test.log

在 Win10 的命令提示符下,一切正常:文件压缩在 ZIP 存档中,7-Zip 的输出写入日志文件。

将此行转为以下 VBScript 示例代码

Dim oWsh: Set oWsh = WScript.CreateObject("WScript.Shell")
Dim s7zip: s7zip = """C:\Program Files (x86)-Zipz.exe"" a c:\Temp\Test.zip c:\Intel\* >c:\Temp\Test.log"
oWsh.Run s7zip

再次导致文件在 ZIP 存档中被压缩,但输出不会写入日志文件,因为根本不会写入任何日志文件。当 Windows shell 中的命令为 运行 时,我猜这种行为与 "StdOut not being StdOut" 有关,但我还没有找到任何解释或解决问题的方法。有人可以帮忙吗?

重定向运算符 (>) 是 CMD 的内置功能。您需要 运行 在 CMD 中执行您的命令才能正常工作。

s7zip = "cmd /c ""C:\Program Files (x86)-Zipz.exe"" a ..."
oWsh.Run s7zip, 0, True