I need to run an install script as an administrator. I tried several things but none of them works
runas /user:Administrator install.bat
The shell asks for the password, then opens a new shell windows, and closes it right away without executing the script
runas /user:Administrator "call install.bat"
The shell asks for the password, then failed with an error
Unable to run - call install.bat
2: The system cannot find the file specified
What I don’t understand is that if I run the command call install.bat without the runas part, the script is ran. It failed for the commands that need admin credentials but that’s expected.
I have 2 questions:
- How to run the script as an administrator using the runas command?
- Could you explain why the following call is not working:
runas /user:Administrator "call install.bat"
Use
cmd.exewhich is your vehicle to interpret.cmdand.batfiles.or
check
cmd.exe /?for/Kand/C.Note:
/Cis more likely what you want.Side-note after your comment:
runashas a/envoption: