I just discovered an answer to something I’ve been trying to work out for a while. I need to run a script that can do some work on Vista machines, but I don’t want the person running the script to have to right-click and do a run-as admin. No easy way of doing that in vbscript, and definitely no way of doing it from the command line that I know yet. If you don’t deal with it in your script then the command will simply fail or Vista will do it’s folder redirect thing.
Anyway I just investigated a tool from Microsoft called STRACE (a socket/SSL tracer designed to generate a trace log for Internet Explorer) and realised it came with a little program called “runelevate.exe”. Intrieged I tried running it from a script in Vista and sure enough whatever you put after the command will request admin privilages, and up pops the UAC dialog 🙂
So just get hold of the strace program from the link above, install it, go to program filesstrace and grab runelevate.exe and you can use it in your scripts in Vista to force a command to run with admin rights like this:
And notepad will run with admin rights!