[英]Passing string(a paragraph) using command line argument to powershell script in php
[英]How to run command line argument using PowerShell script
我可以使用以下命令从Windows CMD安装该软件
setup.exe -inputFile C:\my_installer_input.txt
但是,我想使用PowerShell脚本实现与上述相同的功能。
我从PowerShell这样尝试过
Start-Process -FilePath "C:\Matlab R2018b\setup.exe" -inputFile "C:\my_installer_input.txt" -ArgumentList "/S
并且由于以下原因而无法运行: -inputFile
参数不可用于PowerShell中的Start-Process
。
PowerShell还直接从PowerShell提示符运行本机命令,这意味着您的命令
setup.exe -inputFile C:\my_installer_input.txt
应该直接在PowerShell提示符下工作。
如果在远程计算机上执行,则可以使用Invoke-Command运行,如下所示。
Invoke-Command -Session $session -ScriptBlock { <YOUR CODE HERE> }
要么
Invoke-Command -ComputerName <remote-computername> -ScriptBlock { <YOUR CODE HERE> }
如果在远程计算机上,请执行以下操作:
Invoke-Command -Computername ‘x’ -Scriptblock {
Set-Location C:\path\to\file
cmd /c setup.exe /arg1 /arg2
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.