Run one bat from another bat using elevated privileges.
Posted: 10 May 2013 13:02
This might be simple, but I just can't seem to find anything specifically on how to run the command the way I need it.
Here is my dilemma..
Call it:
Script A
Script B
Script A runs without administrative privileges.. I need Script A to automatically kickoff Script B using admin privileges.
This is what I have so far, and I'm not sure exactly where I'm missing it.
The \"Desktop...\"" seems a bit off but I was referencing one forum where they were doing a similar task with Notepad and it worked, so I tried using the same syntax using cmd.
Running this, it will just kick off a command prompt using elevated privileges, it won't load the bat file.
I've also tried removing the cmd portion and just using the .bat path without quotes, but that doesn't work either..
Just tried this as well, but it's still not working
Here is my dilemma..
Call it:
Script A
Script B
Script A runs without administrative privileges.. I need Script A to automatically kickoff Script B using admin privileges.
This is what I have so far, and I'm not sure exactly where I'm missing it.
Code: Select all
@echo off &cls
SET localname=%COMPUTERNAME%
RUNAS /USER:%localname%\Administrator "cmd \"Desktop\ScriptB.bat\""
pause
The \"Desktop...\"" seems a bit off but I was referencing one forum where they were doing a similar task with Notepad and it worked, so I tried using the same syntax using cmd.
Running this, it will just kick off a command prompt using elevated privileges, it won't load the bat file.
I've also tried removing the cmd portion and just using the .bat path without quotes, but that doesn't work either..
Just tried this as well, but it's still not working
Code: Select all
@echo off &cls
SET localname=%COMPUTERNAME%
RUNAS /USER:%localname%\Administrator "cmd /c ScriptB.bat"
pause