Using REG.EXE, built into Windows XP, Windows Server 2003, Windows Vista, and later operating systems, or installed from the Windows 2000 Support Tools, information from tip 11125 » What is the meaning the State Value Name in a user's registry profile, and GetUserSID.bat, I have scripted IsProfileTemp.bat to determine if the current user has logged on with a temporary profile.

The syntax for using IsProfileTemp.bat is:

\[call\] IsProfileTemp YorN

Where YorN is a call directed environment variable that will contain a Y if the current user's profile is temporary, or an N if it is not temporary.

IsProfileTemp.bat contains:

@echo off                              if \{%1\}==\{\} @echo Syntax: IsProfileTemp YorN&goto :EOF                              setlocal                              set YorN=Y                              call GetUserSID SID                              if "%SID%" EQU "NONE" goto finish                              set key="HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%SID%"                              set /a State=0x800                              for /f "Tokens=2*" %%a in ('reg query %key% /V State^|find "REG_DWORD"') do (                               set /a State=%%b                              )                              set /a ans="%state%&0x800"                              if %ans% NEQ 2048 set YorN=N                              :finish                              endlocal&set %1=%YorN%