1

我正在使用以下 Sub 将参数传递给 Powershell。

     Sub testpower()
      Set WshShell = CreateObject("WScript.Shell")
      WshShell.Run ("Powershell.exe -file .\test.ps1 -path ""Shell.txt"" ")
     End Sub

但是,在VB中运行时不会生成输出,但是如果尝试直接从运行命令运行,它会给出所需的结果。请帮助。

test.ps1 脚本:

 Param([String]$path)
    Get-AuthenticodeSignature $path | Out-File  "C:\Documents and Settings\acmeuser1\output.txt"
4

1 回答 1

0

这个问题基本上是在VBscript 代码中回答以捕获标准输出,而不显示控制台窗口- 那里有几种技术被声明为有效。总而言之,使用WShell.Exec代替WShell.Run,然后通过WShell.StdOut.ReadLine()或捕获输出WShell.StdOut.ReadAll()

于 2016-12-09T23:17:45.213 回答