PowerShell - 启动进程和命令行开关 [英] PowerShell - Start-Process and Cmdline Switches
问题描述
我可以正常运行:
$msbuild = "C:WINDOWSMicrosoft.NETFrameworkv3.5MSBuild.exe"
start-process $msbuild -wait
但是当我运行此代码(如下)时,出现错误:
But when I run this code (below) I get an error:
$msbuild = "C:WINDOWSMicrosoft.NETFrameworkv3.5MSBuild.exe /v:q /nologo"
start-process $msbuild -wait
有没有一种方法可以使用 start-process 将参数传递给 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:WINDOWSMicrosoft.NETFrameworkv3.5MSBuild.exe/v:q/nologo
在单独的一行中,如何在 Powershell 中处理它?
When I have
C:WINDOWSMicrosoft.NETFrameworkv3.5MSBuild.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:WINDOWSMicrosoft.NETFrameworkv3.5MSBuild.exe"
$arguments = "/v:q /nologo"
start-process $msbuild $arguments
这篇关于PowerShell - 启动进程和命令行开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!