New
#1
Powershell start-process with -wait while running as administrator
I need to be able to start a process and have it wait for the process to complete. For example, if I run the below:
start-process notepad -wait
[System.Windows.Forms.MessageBox]::Show("Started running.")
Notepad opens, and after I close it the message box pops up. This is exactly what I want to see except that the process I actually need to run needs to run as administrator. So I run this instead:
start-process notepad -verb runAs -wait
[System.Windows.Forms.MessageBox]::Show("Started running.")
Now Notepad opens and the message displays immediately.
What am I doing wrong?