如何将变量从Windows窗体传递到exe

时间:2019-07-08 19:10:10

标签: powershell powershell-4.0

我试图将ComputerName变量传递给一个Windows窗体,该窗体通过单击按钮打开。用户在$ComputerName.Text框中输入主机名。当他们单击按钮时,应该在$ComputerName.Text中对该主机名运行一个远程命令。现在,我的exe提示通过Read-host进行输入。我希望它只是在文本框中获取变量。

通过将变量添加到行的末尾,我就能以这种方式运行远程控制查看器:

Start-Process -filepath "*\RemoteViewer\CmRcViewer.exe" $ComputerName.Text

我尝试将远程exe更改为从$ComputerName.Text运行,而不是在Read-Host中设置的变量运行。

我的远程命令exe的启动:

$ComputerName = Read-host "Enter IP Address or Host Name"
$Computer = (Get-WmiObject Win32_Computersystem -ComputerName $ComputerName).Name

启动远程进程的功能:

Start-Process -filepath "*remoteprocess.exe" -ArgumentList $ComputerName.Text -WindowStyle Maximized

我希望我的exe抓取$ComputerName.Text变量并在单击按钮时运行它。

0 个答案:

没有答案
相关问题