Last active
August 29, 2015 14:10
-
-
Save childnode/f5f2583f92d515eb97e6 to your computer and use it in GitHub Desktop.
Get correct %LOCALAPPDATA% for SYSTEM user on a win64 system. http://ss64.com/nt/syntax-variables.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set IsSystemUser=0 | |
If "%USERNAME%" == "SYSTEM" Set IsSystemUser=1 | |
If "%COMPUTERNAME%$" == "%USERNAME%" Set IsSystemUser=1 | |
If %IsSystemUser% EQU 1 ( | |
echo "running as system user %USERNAME%"; | |
If NOT %PROCESSOR_ARCHITECTURE% == x86 ( | |
echo "64bit system, looking for WOW64" | |
IF EXIST %SYSTEMROOT%\SysWOW64\config\systemprofile\AppData\Local\NUL ( | |
Set LOCALAPPDATA="%SYSTEMROOT%\SysWOW64\config\systemprofile\AppData\Local" | |
) else ( | |
echo "WARNING C:\Windows\SysWOW64\config\systemprofile\AppData\Local is not readable:" | |
dir %SYSTEMROOT%\SysWOW64\config\systemprofile\AppData\Local | |
echo "Still using %LOCALAPPDATA%" | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment