Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I have remotely connected to a Windows 7 computer via psexec and am running a remote command prompt on the Windows 7 computer. The command I am trying to execute requires that it be run in an elevated command prompt for it to work.

How do I get to an elevated command prompt if my starting point is a command prompt that is not elevated and I don't have access to the GUI?

share|improve this question
Are there any switches in the latest versions of PSEXEC for choosing an elevated context? – nray Oct 25 '09 at 17:58
No------------- – Izzy Oct 25 '09 at 21:09
up vote 5 down vote accepted

I've wrestled with this in the past, and it can't be done. Only way is to create a scheduled task that you then execute from your cmd session.

share|improve this answer
So are you saying that from the command line I can create a scheduled task that will execute under elevated privileges and then manually execute that scheduled task from my current underprivileged command prompt? – Chris Magnuson Oct 25 '09 at 17:47
Yes. Silly isn't it. Make sure you a) select "run with highest privs" and b) don't set a run time for the task. Then execute using schtasks /run – Izzy Oct 25 '09 at 17:48
Can I create the task from the command prompt itself or do I have to create the task trough the GUI to get the elevated privileges? – Chris Magnuson Oct 25 '09 at 17:53
Yes using schtasks – Oskar Duveborn Oct 25 '09 at 18:58

Seems hard to do after you've connected. Microsoft has a Powertoy to install to force elevation in a command, but as the prompt needs to be displayed and accepted I'm at a loss how that would work in your scenario (I guess not at all).

elevate cmd.exe

However, using say Powershell remoting instead would probably solve this as it will elevate when connecting remotely afaik. I guess psexec should be able to implement this kind of support as well - but you'd have to request an elevated context on connection - not afterwards.

Of course, the scheduled tasks trick does seem to work... ^^

share|improve this answer

PSExec has options to specify a username and password, which is required when running a task on a remote computer that requires access to network resources (otherwise PSExec is limited to local resources). Connecting with the appropriate account should give you the access you require: try psexec -u < username > -p

Additionally, the runas command runs a command (even cmd) with the specified privileges. I don't know how nicely it plays with PSExec due to the issue mentioned above, but use the following syntax to elevate priveleges:

runas /user:<domain>\<username> cmd

You will be prompted for a password; if typed correctly, you will be running in a new command prompt with the privileges of the specified account. The privileges may be limited by the privileges PSExec is running with, though.

share|improve this answer
That isn't the same as the elevated token. You can be domain admin, and still not have the elevated token in a command window. – Falcon Momot May 25 '13 at 4:04
what about the -h argument of psexec?… – user236697 Aug 8 '14 at 6:43

In vista you could disable UAC from the cmdline using a script. We used this to disable UAC, reboot the computer, run our scripts/installs, and then enable UAC again before giving the computer a last restart.

I bet Win7 has a similar way of doing this, although I think the command has changed. Thay are just registry settings, though, so it would be fairly easy to script them directly in the registry.

As long as your script is reboot-aware this shouldn't be too hard to implement...


share|improve this answer

Your Answer


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.