JSI Tip 10618. How can I determine if the logged on user has a roaming profile in my domain?

Using REG.EXE, built into Windows XP, Windows Server 2003, and later operating systems, or installed from the Windows 2000 Support Tools, and GETSID.EXE from the Windows XP Support Tools, or a previous Resource Kit, I have scripted CentralProfile.bat to determine if the logged on user has a roaming profile in the domain.

The syntax for using CentralProfile.bat is:

call CentralProfile ANSWER

Where ANSWER is a call directed environment variable that will contain a Y or an N.

CentralProfile.bat contains:

@echo off
if \{%1\}==\{\} goto err1
set sid=N
set key=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileListset CP=N
set OK=N
::call :Q1>nul 2>&1
call :Q1
if "%OK%" EQU "N" goto err2
if "%CP%" EQU "" set CP=N&goto finish
if "%CP:~0,2%" EQU "\\" set CP=Y&goto finish
set CP=N
endlocal&set %1=%CP%
goto :EOF
@echo Syntax: CentralProfile Answer
goto :EOF
@echo Cannot find CentralProfile Value Name for SID: %sid%
endlocal&set %1=N
goto :EOF
for /f "Skip=2 Tokens=*" %%i in ('getsid %LOGONSERVER% %USERDOMAIN%\%USERNAME% %LOGONSERVER% %USERDOMAIN%\%USERNAME%') do (
 set sid=%%i
set sid=%sid:*S-1-=S-1-%
for /f "Tokens=2*" %%i in ('REG QUERY "%key%%sid%" /V CentralProfile^|find "REG_SZ"') do (
 set OK=Y
 set CP=%%j

TAGS: Windows 8
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.