【发布时间】:2013-10-03 09:57:39
【问题描述】:
我正在使用以下 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"
【问题讨论】:
-
您是否尝试过使用文件的完整路径名?
-
是的,我尝试了两种方式..
-
这有点奇怪,因为它对我有用。运行脚本后是否创建了 C:\Documents and Settings\acmeuser1\output.txt 文件?除了 Get-AuthenticodeSignature 的输出之外,您是否尝试过向其输出其他内容?
-
我犯了一个错误,它现在对我有用..我想每次都更改路径的值,在这种情况下是“Shell.txt”。如何?
-
这就是我现在想要做的..Sub testpower() Set WshShell = CreateObject("WScript.Shell") k = Chr(34) & "C:\Documents and Settings\acmeuser1\ 1.vbs" & Chr(34) 'filepath = "" & "C:\Documents and Settings\acmeuser1\1.vbs" & "" WshShell.Run ("C:\WINDOWS\system32\WindowsPowerShell\v1.0\ Powershell.exe -file test.ps1 -path k ") End Sub
标签: powershell vbscript