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
How do i reduce wait time for delayed start services
I have a windows service that talks to a usb device, (i wrote it) all was well until i installed a SSD drive, now the PC boots before the device is ready to talk :( I set Automatic(Delayed) and that fixed my problem, but i have to wait 2 minutes for the service to start. Thats far too long when...
Performance & Maintenance
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
Windows start up as usual. Please wait is stuck, with a black screen.
I didn't know where exactly this should go, so let me know if there is somewhere else it should be. I was cruisin' through the internet, next thing I know the only page that will load is the new tab page. So, like any hard working male, I restart my computer. Well, when i try to restart it after...
General Discussion
How many process are you running on Windows 7?
I'm running about 53 processes, W764 :shock:
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 20:49.
Twitter Facebook Google+