Subscribe to Windows IT Pro
December 22, 2006 12:00 AM

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

Windows IT Pro
InstantDoc ID #94679
Rating: (0)

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%


Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.