Windows – Batch – Return a Profile Using Marker File

email me

This is a code snippet from a larger script. I’m using it to return a “marked” profile.

if not exist D:\Users for /f "tokens=1 delims= " %%a in ('dir /b c:\users') do (
set profile=%%a
if exist C:\users\%profile%\desktop\marker.txt goto :eof
)

echo Detected migration profile: C:\users\%profile%

 

Output

Detected migration profile: C:\users\myuser

 

Notes

reg Query “HKLM\Hardware\Description\System\CentralProcessor\0” | find /i “x86” > NUL && set OS=32BIT || set OS=64BIT

if %OS%==32BIT goto 32Bit
if %OS%==64BIT goto 64Bit