JSI Tip 5346. How do I retrieve a user's ProfileImagePath in batch?
May 22, 2002
When a user logs onto a Windows NT-based computer (Windows NT 4.0, Windows 2000, and Windows XP),
their local profile is stored at the location specified in the registry at:
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionProfileListProfileImagePath.
I used this information to allow a user to:
use their domain profile while logged on locally to Windows 2000 or Windows XP
use their domain profile while logged on locally to Windows NT 4.0
to make a program available to all users
to recovery a lost local profile.
Microsoft used this information to alter the location of the user's local profile.
Using REG.EXE on Windows 2000, from the Windows 2000 Support Tools, or REG.EXE built into Windows XP,
and UserSID.bat, I have scripted ProfileImagePath.bat, to retrieve the location of a user's local profile.
The syntax for using ProfileImagePath.bat is:
call profileimagepath \DC_or_Local UserName \Local_Computer
where:
\DC_or_Local is either a domain controller, if you want the domain SID, or the local workstation, if the UserName is local.
UserName is the User Account whose SID you want.
\Local_Computer is the local computer that contains the user profile.
ProfileImagePath.bat returns the ProfileImagePath environment variable, %ProfileImagePath%.
ProfileImagePath.bat contains:
@echo offIf {%3}=={} goto syntaxif not exist %1c$ goto syntaxif not exist %3c$ goto syntaxcall UserSid %1 %2for /f "Skip=3 Tokens=2*" %%i in ('reg QUERY "%3HKLMSOFTWAREMicrosoftWindows NTCurrentVersionProfileList%sid%" /v ProfileImagePath') do set ProfileImagePath=%%jgoto :EOF:syntax@echo Syntax call ProfileImagePath \DC_or_Local UserName Local_Computer
NOTE: If you wanted to change the location of the local profile, you would:
reg ADD "\Local_ComputerHKLMSOFTWAREMicrosoftWindows NTCurrentVersionProfileList%sid%" /v ProfileImagePath /t REG_EXPAND_SZ /d "" /f>nul 2>&1
About the Author
You May Also Like