Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Powershell start-process with -wait while running as administrator

16 Feb 2016   #1

Windows 7 Professional 64 bit
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?

My System SpecsSystem Spec
18 Feb 2016   #2

Windows 7 32 bit

I am no PS aficionado but this page seems to imply you need to run powershell itself as admin first. See the example at the bottom:
My System SpecsSystem Spec

 Powershell start-process with -wait while running as administrator

Thread Tools

Similar help and support threads
Thread Forum
Process - See if running as administrator (elevated)
How to See if Process is running as administrator (elevated) in Vista and Windows 7 This tutorial will show you how to determine if a program or process is running as administrator (elevated) or not in Vista and Windows 7. Here's How:
How to run PowerShell scripts easily from start menu
Hi, I have a very big problem :p I put 2 scripts in C:\Windows (pong.ps1 and pung.bat). And I added ".PS1" in the PathExt environment variable. But : When I clic Start button, and type pung, my batch script pung.bat appears in the Programs list and is selected so I just need to press to...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 23:55.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App