Description
On modern Windows 10 and Windows 11 systems, the file paths
%SYSTEMROOT%\SysWOW64\config\system
%SYSTEMROOT%\system32\config\system
do not exist. These paths were used in older privilege-checking batch file techniques, but Microsoft has since hardened system directories and registry hives. Trying to access these on Windows 11 will typically result in an error, even when run as administrator.
Implications for your script
The script attempts to check for administrator rights by accessing these files with cacls.exe.
On Windows 11, this check will always fail because the files don’t exist, meaning the script will always try to re-launch itself with elevated privileges, or just fail the privilege check.
What to do instead?
A more robust, modern approach for checking admin rights in batch scripts is to use the NET SESSION command:
batch
net session >nul 2>&1
if %errorLevel% neq 0 (
echo Requesting administrative privileges...
goto UACPrompt
) else (
goto gotAdmin
)
net session requires admin rights, but doesn’t rely on deprecated or non-existent files.