'batch-script start another batch-script as administrator [duplicate]
In school, we have Notebooks and every student has his own account, after sing out the desktop will be cleaned from files, so I have to install every single time some programs and packages.
To save time, I wanted to make it autonomous, so I made a script and saved it on my drive.
My next problem was, that I have to copy the script to the desktop and run there as admin, so I need a command who does it for me. When I searched for a solution, I often find that they become the network administrator (with "runas /user:Administrator...") and not just when you right-click on the file and run it as administrator.
Does anyone know the command to run a batch-script as administrator?
Solution 1:[1]
This should work but when I did it in school they took my computer and now I cant take my computer home anymore because I was not meant to have admin so be careful I guess.
nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" if '%errorlevel%' NEQ '0' ( goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" set params = %*:"=" echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Pebbled |