Is the HOME environment variable normally set in Windows?
To be clear, I'm not asking can it be set or how to set it, I'm asking is it already set at all on a new copy of Windows. The ideal way to find this out would be to install a fresh copy of Windows on a VM and check, since most of everybody who can answer this question will already have it set ;-)
I need to know if I can depend on it always being there. (I understand that these can be unset, but if you know how to do that you know you're asking for trouble.)
No, it is not. The closest equivalents in Windows NT are %UserProfile%
and %HomeDrive%%HomePath%
(note that they may point to different locations – the profile is always local, while the home can point to a network share).
No.
The equivalent environment variables that are set are HOMEDRIVE
and HOMEPATH
.
There's also %LOCALAPPDATA%
(never roaming) and %APPDATA%
(can roam). You're not supposed to write to %UserProfile%
directly, and you can't predict the relative path from %LOCALAPPDATA%
to %APPDATA%
(could be localized).