[英]Pass a variable to a psexec powershell command in vbscript
I'm trying to pass the user input computer name to the psexec command. 我正在尝试将用户输入的计算机名称传递给psexec命令。 I've tried about everything. 我已经尝试了一切。 I know the command works because if I run the file by manually entering the computer name is successful. 我知道该命令有效,因为如果通过手动输入计算机名称运行文件成功。 I need to get the strComputer variable into the \\strComputer psexec command. 我需要将strComputer变量放入\\ strComputer psexec命令中。 Thanks in advance. 提前致谢。
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")
Why not use a PowerShell script for this? 为什么不为此使用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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.