从Powershell脚本使用参数运行可执行文件 [英] Run Executable from Powershell script with parameters
本文介绍了从Powershell脚本使用参数运行可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有一个powershell脚本,它应该运行一个可执行文件的参数传递设置我想运行的方法,我需要传递一个参数,这是一个目录到一个配置文件。所以这是我有
So I have a powershell script that is supposed to run an executable with an argument to pass to set which method I want to run, and I need to pass a parameter, which is a directory to a config file. So this is what I have
Start-Process -FilePath "C:\Program Files\MSBuild\test.exe" -ArgumentList /genmsi/f $MySourceDirectory\src\Deployment\Installations.xml
f是短名称,文件是我的属性的长名...我在powershell中得到一个错误,告诉我无法找到/ f或/ file的位置参数。
/f is the shortname and file is the long name for my attribute... I get an error in powershell telling me that a positional parameter cannot be found for /f or /file.
任何想法?
推荐答案
我能够使用 Invoke-表达式
cmdlet。
I was able to get this to work by using the Invoke-Expression
cmdlet.
Invoke-Expression "& `"$scriptPath`" test -r $number -b $testNumber -f $FileVersion -a $ApplicationID"
这篇关于从Powershell脚本使用参数运行可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文