PowerShell - 启动过程和Cmdline开关 [英] PowerShell - Start-Process and Cmdline Switches
问题描述
我可以运行这个罚款:
$msbuild = "C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe"
start-process $msbuild -wait
但是当我运行这个代码(下面),我得到一个错误:
But when I run this code (below) I get an error:
$msbuild = "C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /v:q /nologo"
start-process $msbuild -wait
有没有办法我可以传递参数给MSBuild使用start-process?我开放不使用启动过程,唯一的原因,我使用它是我需要有命令作为一个变量。
Is there a way I can pass parameters to MSBuild using start-process? I'm open to not using start-process, the only reason I used it was I needed to have the "command" as a variable.
当我有
C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /v:q / nologo
在一行上,在Powershell处理?
When I have
C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /v:q /nologo
on a line by itself, how does that get handled in Powershell?
我应该使用某种类型的eval()函数吗?
Should I be using some kind of eval() kind of function instead?
推荐答案
您将要将参数分成单独的参数
you are going to want to separate your arguments into separate parameter
$msbuild = "C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe"
$arguments = "/v:q /nologo"
start-process $msbuild $arguments
这篇关于PowerShell - 启动过程和Cmdline开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!