At least XP has a runas command that you can try using, for example:
runas /u:%COMPUTERNAME%\Administrator "cmd /c service.bat install"
When called, it asks for a password on the console.
UPDATE: six months later I upgraded to Windows 7. Here, runas cannot be used to elevate privileges, but Aaron Margosis solution:
// elevate.js -- runs target command line elevated if (WScript.Arguments.Length >= 1) { Application = WScript.Arguments(0); Arguments = ""; for (Index = 1; Index < WScript.Arguments.Length; Index += 1) { if (Index > 1) { Arguments += " "; } Arguments += WScript.Arguments(Index); } new ActiveXObject("Shell.Application").ShellExecute(Application, Arguments, "", "runas"); } else { WScript.Echo("Usage:"); WScript.Echo("elevate Application Arguments"); }
Perhaps it can be built into the installer, if necessary. However, for end users, Script Elevation Power Toys is more compelling, as suggested by another answer.
Laurynas biveinis
source share