4

This question is different from Run as administrator from command line on Windows 8 and I wrote why: I want to run a program a) as a different user b) get elevated privileges (which is additionally required to executing as admin as per UAC) and c) pass the original environment. The linkes article only covers a+b.

I just saw that "runas /user:admin /env cmd.exe" which used to work in WinXP does not work in Vista+ any more due to UAC: An additional elevation is required.

What is the best/shortest (in the sense that I do not need to install a program; copying small auxiliary exes would be OK) to achieve:

  • Starting an exe as admin (i.e., a different user in the admin group)
  • Additionally, with elevated privileges
  • Keep the environment of the current users
  • Permits to supply parameters to the executed program

I found the "Elevation PowerToys for Windows Vista" and tried:

runas /user:admin /env "%USR%\bin\Elevate.cmd \"%COMMANDER_EXE%\""

but this has one show-stopper and some shortcomings:

  • Even though I use "/env" the executed program does not inherit the environment
  • The 3-fold nested parameters makes it difficult to supply more complicated parameters to %COMMANDER_EXE%
  • I would prefer a normal/graphical window to enter the password rather than a cmd window
  • After the runas, the UAC dialog additionally pops up (would be good to have this together)
divB
  • 629

0 Answers0