I can run this fine:
$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
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.
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?
Should I be using some kind of eval() kind of function instead?
The Start-Process cmdlet allows you to run one or multiple processes on your computer from within PowerShell. It's designed to run a process asynchronously or to run an application/script elevated (with administrative privileges).
Find the name of the process and record the PID or image name (i.e., notepad.exe). To kill the process on PowerShell, use any of the following commands: To gracefully kill the notepad process with pid: taskkill /pid 13252. To forcefully kill the notepad process with pid: taskkill /pid 13252 /f.
You can name 'Start-Powershell' (name of the Function) whatever you like. This is your new "Alias" which works in your user environment and with auto-completion.
Step 1: Press the Windows + R keys together to bring up the Run dialog box. Step 2: Type the PowerShell in the box and click OK button. A normal Window PowerShell will launch as a current user. Step 3: Type the command start-process PowerShell -verb runas and press "enter" key.
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
Using explicit parameters, it would be:
$msbuild = 'C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe' start-Process -FilePath $msbuild -ArgumentList '/v:q','/nologo'
EDIT: quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With