Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Within Windows Explorer, I can right click on an executable file and pick 'Run as administrator' which will launch the selected process with elevated privileges or I can shift-right click on the executable file and click 'Run as different user', specify the username and password which will launch the process with standard privileges using the specified user context.

How do I run as a different user AND run in an elevated context? A perfect example of this would be opening an elevated command prompt using a different user context that the currently logged in user.

share|improve this question
    
I think powershell the start-process command might be able to do this. – jiggunjer Jan 17 at 15:02
up vote 7 down vote accepted

I don't think such an option exists.

As a work around you could start the command line as an admin and execute the following command to run the command line with admin privileges as the other user.

runas /netonly /user:YourUser cmd.exe

share|improve this answer
2  
Or you can right click the executable, then select properties>compatability and then select Privilege Level and check Run this program as an administrator. Then shift right click the executable and run as a different user. – NewProgrammerJames Oct 18 '13 at 21:02
    
@NewProgrammerJames Nice, thanks for the input :) – Yass Oct 18 '13 at 22:22
    
@NewProgrammerJames This trick doesn't work with CMD directly on W2008R2 and above, but tweaking a custom app should be possible. – Vesper Jul 2 '15 at 7:52
    
This will work even if the end user isn't in the admin group? – jiggunjer Jan 17 at 14:56
    
@jiggunjer No, as far as I know. – Yass Jan 17 at 14:57

Yes, psexec absolutely does this.

The following example works cleanly on Windows 8.1; run the command prompt as Administrator, then:

// -i makes the app interactive
// -h elevates the execution context 
// Omitting the password forces a secure prompt
psexec -u DOMAIN\user -i -h "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe"
share|improve this answer
    
From Mike: This works for Windows 10! – fixer1234 Dec 24 '15 at 9:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.