Pass a comand on a batch with admin privileges
Posted: 26 Dec 2020 12:28
I have updated 2 of my tools with a admin privileges script.
IFEO Tool V2
https://filecrypt.cc/Container/509C3613D0.html
Firewall Blocker for Windows V3
https://filecrypt.cc/Container/DADEB77E7D.html
The problem is if i pass a command (for example: bat.bat /test1) /test1 will not pass along.
Is there any fix for this?
The code i added is here:
Thanks
Check my "batches"
http://www.cyberlord.at/forum/?id=10589&forum=73587
IFEO Tool V2
https://filecrypt.cc/Container/509C3613D0.html
Firewall Blocker for Windows V3
https://filecrypt.cc/Container/DADEB77E7D.html
The problem is if i pass a command (for example: bat.bat /test1) /test1 will not pass along.
Is there any fix for this?
The code i added is here:
Code: Select all
@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"
:--------------------------------------
Check my "batches"
http://www.cyberlord.at/forum/?id=10589&forum=73587