Q. How can a batch determine if the current user is using a temporary profile?

Jerold Schulman

December 21, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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 offif {%1}=={} @echo Syntax: IsProfileTemp YorN&goto :EOFsetlocalset YorN=Ycall GetUserSID SIDif "%SID%" EQU "NONE" goto finishset key="HKLMSOFTWAREMicrosoftWindows NTCurrentVersionProfileList%SID%"set /a State=0x800for /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:finishendlocal&set %1=%YorN%


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like