使用参数从 Powershell 脚本运行可执行文件 [英] Run Executable from Powershell script with parameters

查看:52
本文介绍了使用参数从 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 FilesMSBuild	est.exe" -ArgumentList /genmsi/f $MySourceDirectorysrcDeploymentInstallations.xml

/f 是我的属性的短名称,file 是我的属性的长名称...我在 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-Expression 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆