What is the meaning of these Windows Environment variables:
- HOMEDRIVE,
- HOMEPATH,
- HOMESHARE,
- and USERPROFILE?
Who set them? When? Who use them? For doing what?
How the configuration of the samba server modify these variables?
What is the meaning of these Windows Environment variables:
Who set them? When? Who use them? For doing what?
How the configuration of the samba server modify these variables?
USERPROFILE
is set by userenv!LoadUserProfileW
which is called when, well, loading the user's profile (the HKEY_USERS\<sid>
hive).
/noprofile
for runas
) then the process is run in the Default User
profile which still has this variable set - since the moment it was loaded at system's startup.HOMEDRIVE
, HOMEPATH
and HOMESHARE
(as well as several other variables) are set by shell32!RegenerateUserEnvironment
which is called on Explorer initialization1. They are placed in the (volatile) HKCU\Volatile Environment
key which, being volatile, persists until the profile's unload.
USERPROFILE
nowadays.HOMEPATH
to be set, SYSTEM
must have permissions for the profile's directory (they are initially set, of course, but may vanish when e.g. playing with Cygwin's chmod
).1The code also sets a few variables that are already set by userenv
. This suggests that this is older code that persists since NT4 days. Difference between profile and home path - Server Fault confirms that.
HOMEDRIVE
/HOMEPATH
is where the user's personal files are: downloads, music, documents, etc.
HOMESHARE
is used instead of HOMEDRIVE
if the home directory uses UNC paths.
USERPROFILE
is used to store the user's application and OS configuration files and personalization settings. It includes both local and roaming (Active Directory) folders. It seems like people favor using this more than HOMEPATH
nowadays.
It's important to note that although HOMEDRIVE
/HOMEPATH
is often the same path as USERPROFILE
, it's not always the case.
I don't think Samba would modify these. It might make use of them to provide an initial (home) directory. Active Directory may change them though.
References:
net user <username> /HOMEDIR:<path>
can set it (there since at least win2k). –
Glabrous if you go to the run box and type any of the above like this
%HOMEPATH%
then it will go to your environment path that is set on your machine. It's usefull when writing vb scrips and things like that where you want to perform a task on the users profile area for example.
Hope this helps
\
(%HOMEDRIVE% is Z:
) and if I put %HOMEPATH% in the Run window, it opens C:\
... (now, I can't guarantee it would always open that specific drive) –
Elenoraelenore Those are all set on login, and they are, as SocialAddict said, very useful in scripts when you need to perform an action on different systems.
I'm not too clear on your other question, a samba server shouldn't care about those variables.
See http://vlaurie.com/computers2/Articles/environment.htm for a detailed explanation.
© 2022 - 2024 — McMap. All rights reserved.