Powershell start-process with -wait while running as administrator


  1. Posts : 28
    Windows 7 Professional 64 bit
       #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?
      My Computer


  2. Posts : 5,092
    Windows 7 32 bit
       #2

    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:

    https://technet.microsoft.com/en-us/.../hh849848.aspx
      My Computer


 

  Related Discussions
Our Sites
Site Links
About 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 13:02.
Find Us