locked
Run EXE as Adminstrator RRS feed

  • Question

  • Hey Scripting Guys & Gals!

    I'm trying to execute an exe file as administrator.  Pretty much the same manner as when you right-click the exe and select 'run as administrator'.  I'm running Powershell 2.0 as administrator and executing the exe file with Start-Process, but that method is not functioning correctly. Any suggestions?

    Many Thanks!


    • Edited by NeedAnswers8 Thursday, November 13, 2014 7:54 PM Mistakenly being viewed as a ConfigMgr question
    Thursday, November 13, 2014 6:37 PM

Answers

  • You can do this with start-process

    Start-Process -FilePath $WordAddonEXE -Wait -Verb runas

    • Proposed as answer by jrv Thursday, December 4, 2014 10:01 AM
    • Marked as answer by Bill_Stewart Tuesday, December 30, 2014 2:46 AM
    Thursday, December 4, 2014 9:31 AM

All replies

  • We get this question at least 10 times a month.

    You cannot bypass the UAC prompt, and this is by design.

    There is a long list of good reasons why.

    FAQ: Why can't I bypass the UAC prompt?

    But since you are asking a SCCM question, you should ask in an SCCM forum.


    -- Bill Stewart [Bill_Stewart]

    Thursday, November 13, 2014 7:05 PM
  • You have the option to run the program with admin rights, which will run your application as Local System. This is how I handle script deployment.

    I agree with Bill, you should ask ConfigMgr questions in the ConfigMgr forums:

    https://social.technet.microsoft.com/Forums/en-US/home?category=systemcenter2012configurationmanager&filter=alltypes&sort=lastpostdesc


    Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)

    Thursday, November 13, 2014 7:12 PM
  • Scripts run under ConfigMgr do not need elevation.  Scripts run against CM must be elevated for many operations.


    ¯\_(ツ)_/¯

    Thursday, November 13, 2014 7:26 PM
  • The original answer hasn't changed. No matter whether SCCM is involved or not, if you log on as a standard user (or even an administrator) when UAC is enabled, you cannot bypass the UAC prompt when elevating. This is by design. The FAQ link I posted explains why, and why this is a good thing.

    -- Bill Stewart [Bill_Stewart]


    • Edited by Bill_Stewart Thursday, November 13, 2014 10:53 PM
    Thursday, November 13, 2014 10:53 PM
  • ...unless you aren't asking how to bypass the UAC prompt. If you are asking how to provoke the UAC prompt when starting a process that requires elevation, that's a different question. If that's your question (how to elevate a process and provoke the UAC prompt), you need to tell exactly what command you're running and what specifically isn't working.

    -- Bill Stewart [Bill_Stewart]

    Thursday, November 13, 2014 10:58 PM
  • Hey Scripting Guys & Gals!

    I'm trying to execute an exe file as administrator.  Pretty much the same manner as when you right-click the exe and select 'run as administrator'.  I'm running Powershell 2.0 as administrator and executing the exe file with Start-Process, but that method is not functioning correctly. Any suggestions?

    Many Thanks!


    If the script is being run at a prompt then UAC rules. If under CM then CM rules. You cannot overcome this at a prompt but CM has the rights to bypass.

    Some EXEs cannot be run because they also violate security considerations.


    ¯\_(ツ)_/¯

    Thursday, November 13, 2014 11:55 PM
  • Hello Bill,

    I would like to know how to provoke the UAC prompt.  I'm attempting to install a MS Word Add-on that will only install if I right-click, select Run as administrator (shown below), and select yes at UAC. 

    Here's what I have in my script:

    $WordAddonEXE = "${filePath}\MasterControlWord.exe"

    Start-Process -FilePath $WordAddonEXE -Wait

    This executes the EXE, but it doesn't complete successfully (does not show installed in MS Word Add-Ins).  So I would like to know how I can execute this exe file and get the UAC prompt.  Thank you for your patience!

    

    Friday, November 14, 2014 7:20 PM
  • Try a utility I wrote called elevate32 (32-bit) or elevate64 (64-bit). This is a small .exe file that provokes the UAC prompt and runs any command you specify.


    elevate32 d:\path\mastercontrolword.exe


    If the installer is 32-bit (likely), then use elevate32.exe.

    You can get it here: http://www.westmesatech.com/misctools.html (file is elevationtoolkit1.zip)


    -- Bill Stewart [Bill_Stewart]

    Friday, November 14, 2014 7:29 PM
  • You can do this with start-process

    Start-Process -FilePath $WordAddonEXE -Wait -Verb runas

    • Proposed as answer by jrv Thursday, December 4, 2014 10:01 AM
    • Marked as answer by Bill_Stewart Tuesday, December 30, 2014 2:46 AM
    Thursday, December 4, 2014 9:31 AM
  • You can do this with start-process

    Start-Process -FilePath $WordAddonEXE -Wait -Verb runas

    That works but you will still get the prompt.


    ¯\_(ツ)_/¯

    Thursday, December 4, 2014 10:01 AM