Sometimes you may open a program that you want to run as an administrator, but you may already have opened it not as an administrator. Is it possible to elevate the privileges of an already running program in Windows 7 or do I have to close and restart as admin?

  • 10
    sudo for the win!
    – Josh K
    Apr 9 '10 at 2:57
  • 1
    @Josh K - er - How can you elevate an already running app using sudo ?
    – Sathyajith Bhat
    Apr 9 '10 at 3:30
  • It's magical, you'd have to decode man sudo for more information.
    – Josh K
    Apr 9 '10 at 3:58
  • 2
    @Josh, if nothing else, you can always use pseudo ;) Jul 16 '10 at 22:44
  • 1

Unfortunately, no. A running process cannot be elevated to administrator privileges. I'm looking for a more authoritative source, but for now I have found:

  1. "Programs can't be elevated once they've already been launched..."

  2. "Code can only be elevated at process level when startup, which means that a running process cannot be elevated."

  • 3
    This is absolutely untrue. The win32 API does support elevation of arbitrary applications that are already running, though the application in question must expose the functionality itself. This article and accompanying source code demonstrate how to accomplish this. It is conceivably possible that one could write an application to select and elevate other processes...
    – Fopedush
    Dec 23 '13 at 19:13
  • 9
    @Fopedush Although that article describes this technique as "self-elevating", what those example programs seem to actually be doing is launching a new instance of the process using ShellExecuteEx and the verb "runas". I don't think that achieves the OP's need to elevate a program that's already running (it will lose all of its state, for example). Dec 23 '13 at 23:47
  • when a non-elevated Total Commander 8.01 instance is blocked in an operation such as copying into a program files subfolder, it offers the possibility to "retry as administrator". Cannot this be extended to "foreign" (not self) processes?
    – n611x007
    Dec 27 '13 at 17:18
  • 3
    @naxa I haven't used Total Commander, but I'd be willing to bet the "retry as administrator" option actually spawns a completely separate elevated process which performs the privileged work. Process Explorer does this when you choose "Show details for all processes", it launches a new elevated copy of itself and closes the unelevated copy. If that's the case, then programs need to be specifically written to know how to launch the second process correctly. Dec 27 '13 at 19:49
  • 1
    @StephenJennings You're completely right - the code sample I linked does in fact just relaunch with the runas command. I should have vetted the code in addition to the article before commenting. I had been under the impression that the WIN32 api did expose some kind of elevation mechanism - but perhaps I'm misremembering. I'll dig around and post again if I can find what I was thinking of.
    – Fopedush
    Dec 31 '13 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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