Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run PowerShell Start-Process without closing the output window?

I am trying to run the following PowerShell command in CMD:

powershell -Command "Start-Process MSBuild.exe MyProject.sln -Verb RunAs"

I'm running this in PowerShell so that I can get the UAC (for elevated privileges). I'm not sure if there is an equivalent in CMD.

Now, I run the PowerShell script from within a batch file, so that I can double-click and execute. (or put it in the $Path location and call it from anywhere)

But the problem is as soon as it finishes running, it immediately closes, and I cannot see the build error message if any.

How can I wait or pause when MSBuild.exe has finished executing in a new window?

like image 690
ANewGuyInTown Avatar asked Nov 23 '25 15:11

ANewGuyInTown


1 Answers

The noexit command keeps your PowerShell window open.

powershell -noexit -Command "Start-Process MSBuild.exe MyProject.sln -Verb RunAs"

like image 151
coinbird Avatar answered Nov 25 '25 06:11

coinbird