5

Possible Duplicate:
Elevate a running program to administrator (Windows 7)

Situation:

  1. I start a command prompt normally, without Administrator permissions, either accidentally by habit or intentionally because I don't plan on doing anything that requires elevated privleges.

  2. After some work, it turns out I actually do need to run something from the command line with elevated privileges.

Question:

  • How can I do this?

Parameters & Assumptions:

  1. I want to do this without going outside of the existing CMD window. (I know all about Ctrl+Shift+Enter in the Start Menu, and "Run As" in context menus. I know runas at the command line might be an option, but this would force creation of a new CMD window. I want to elevate an existing, non-privileged CMD window.)

  2. I do not want to enable or create any additional accounts.

  3. The built-in Administrator and Guest accounts (SIDs 500 & 501) are disabled, and either do not have passwords set or have very complex and human-unfriendly passwords configured. I want to keep them this way.

  4. My account is a member of the Administrators group.

  5. I'd rather do this with built-in tools only (Windows 7 Ultimate). Second preference would be Sysinternals or other Microsoft-provided add-ons. Third-party tools are a last resort option.

  6. While runas or sudo type functionality would probably be sufficient to solve this problem, I'd really like something that operates more like su - give me an elevated prompt from which I can run commands until I'm done with it.

  7. Ideally, I'd like this to be easily reversible - I want to be able to return to a non-elevated state within the same CMD window.

5
  • 1
    I don't think it's possible to elevate a process in-place, i.e. the process must be started with the desired elevation level.
    – Bob
    Commented Apr 24, 2012 at 14:32
  • Have you checked superuser.com/questions/42537/… ? Commented Apr 24, 2012 at 14:36
  • Looks like Oliver's link might be the killer for this question, but the link Horst gives has an answer (not the accepted one, but further down) that points to some "Power Toys" which may be of use. Unfortunately, the Power Toy seems to be more like sudo when I'm really looking for su.
    – Iszi
    Commented Apr 24, 2012 at 15:02
  • 1
    Have a look at this, not sure if it is what you need...jpassing.com/2007/12/08/…
    – Moab
    Commented Apr 25, 2012 at 1:05
  • @Bob, It actually IS possible to elevate in process and is how certain elevated action buttons exist (i.e. in Explorer). But it requires you to load an elevated COM component. Commented Jul 18, 2017 at 14:22

1 Answer 1

4

Elevation spawns a new process -- it doesn't elevate an existing process. I don't believe what you want is possible. UAC operates under a dual token method where even if you have the right to have elevated access, until you request it via UAC its not provided. Once requested its a new process.

3
  • I believe this is the case.
    – Shinrai
    Commented Apr 24, 2012 at 14:46
  • I understand the new command prompt would run as a separate process. I just don't like the hassle of dealing with entirely separate windows. I was hoping there might be some way to make it behave more like the su command in Linux - sure, the actual session may be different, but there's no window-switching involved on the user end.
    – Iszi
    Commented Apr 24, 2012 at 14:59
  • @Iszi I have a hard time coming up with a secure way to implement this. Commented Apr 24, 2012 at 15:59

Not the answer you're looking for? Browse other questions tagged .