将变量传递给vbscript中的psexec powershell命令

时间:2014-01-21 17:18:50

标签: powershell command-line vbscript psexec

我正在尝试将用户输入计算机名称传递给psexec命令。我试过一切。我知道该命令有效,因为如果我通过手动输入计算机名称来运行该文件是成功的。我需要将strComputer变量放入\ strComputer psexec命令。提前谢谢。

Set objShell = CreateObject("Wscript.shell")

Dim strComputer

strComputer=InputBox("Run app on remote computer",,"Type name here & click OK")

objShell.run("powershell psexec.exe -i -s \\strComputer \\domain.com\folder\app.exe domain.com")

MsgBox("Scan complete")

1 个答案:

答案 0 :(得分:0)

为什么不为此使用PowerShell脚本?

Contents of myscript.ps1
------------------------
$computerName = Read-Host "Enter name of remote computer"
psexec \\$computerName -i -s \\domain.com\folder\app.exe domain.com
"Scan complete"
相关问题