|
Answer» i want to make my batch files run there self invisible while requesting for UAC after the computer retarts, how ever if the UAC fails to retrieve elevation, i want to continue the batch script while still running invisible. How can i do this?
this is my script
Code: [Select]echo off ::copies itself to temp folder if not exist "%TEMP%\%~NX0" ( copy %0 "%TEMP%\%~NX0" ) ::uses vbs file to run itself invisible with uac if not exist "%TEMP%\%~N0.vbs" ( echo set shell=CREATEOBJECT^("Shell.Application"^) > "%TEMP%\%~N0.vbs" echo shell.ShellExecute "%TEMP%\%~NX0",,, "runas", 0 >> "%TEMP%\%~N0.vbs" echo set shell=nothing >> "%TEMP%\%~N0.vbs" ) ::puts itself on startup using registry reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "%~N0" > nul 2> nul || ( reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "%~N0" /t REG_SZ /f /d "%TEMP%\%~N0.vbs" )
it works but it cant continue the batch script like the code bellow does? this script is allowed to continue after prompting uac, is it possible to apply it to the above script? if so, which part makes it possible and how can i apply it to the above script.
Code: [Select]echo off
:: BatchGotAdmin :------------------------------------- REM --> Check for permissions IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" ( >nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" ) ELSE ( >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" )
REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo Requesting administrative privileges... 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" exit /B
:gotAdmin pushd "%CD%" CD /D "%~dp0" :-------------------------------------- <YOUR BATCH SCRIPT HERE>
i basically just need a batch file that is RAN invisible at the same time that it requestes for uac, but still continues if uac fails to get admin thanks
|