Vista is quite nice in keeping you from running too many things at elevated rights so you don’t get into trouble. Where things breakdown are when you want to start a particular process with elevated rights from a command line. The RUNAS program does not have any switch to run a program with your user credentials, but let you bump the rights. In addition, if you use RUNAS to start a process that requires elevation, you’ll just get an error 740 saying “The requested operation requires elevation.” For us old command line jockey’s this is not a satisfying situation.
If you want a program to always run with elevated privileges, you can always right click on it in Explorer, select Properties and in the Compatibility tab, tell the operating system you want to always run this program as an administrator.
The only problem is that there are numerous programs you don’t want to use the “always elevate” sledgehammer on permanently. For example, I don’t run Visual Studio elevated, but there are times when I need to use it elevated. While I could start a separate console with elevated rights, switch to it, and execute the program, that’s strikes me as a far too much work when I can write a program instead! Thus Elevate was born. Just execute “elevate notepad” and you’ll be prompted with the UAC prompt to run notepad right from the command line.
Elevate will take numerous command line arguments to make your command life a little bit easier and to potentially be used in batch or script files. Here’s the help from the program:
(c) 2007 – John Robbins – training.atmosera.com
Execute a process on the command line with elevated rights on Vista
Usage: Elevate [-?|-wait|-k] prog [args]
-? – Shows this help
-wait – Waits until prog terminates
-k – Starts the the %comspec% environment variable value and
executes prog in it (CMD.EXE, 4NT.EXE, etc.)
prog – The program to execute
args – Optional command line arguments to prog
Note that because the way ShellExecute works, Elevate cannot set the
current directory for prog. Consequently, relative paths as args will
probably not work.
As you can see, Elevate works with %COMSPEC% so my beloved 4NT works as well. Down load the source from here.
The magic that Elevete uses? Passing “runas” as the verb to ShellExecute.
TechRepublic Senior Writer Dan Peterson interview with Atmosera Chief Marketing Officer John Trembley. The video focuses on digital transformation tips and best practices for enterprise companies.
The cloud can be a tough transition for legacy enterprise companies
…Continued on the TechRepublic Website