Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any environment variable that represents "C:\Documents and Settings" folder or C:\Users folder in Windows?

Is there any environment variable or Other format that the profile path is represented in Windows? I want to query in such a way that I should get the value "C:\Documents and Settings (if windows XP or 2k3) or C:\users (If vista or windows 7).

I dont want the current user name appended to the string, which I can get thru %USERPROFILE% variable.

like image 900
svv Avatar asked Dec 21 '10 21:12

svv


People also ask

What is C :\ Documents and Settings?

It is a just a link pointing to the new locations. All user's profiles are located under C:\users. Here you can find your Desktop, Documents, etc. If you need to see the C:\Documents and Settings link, first you have to enable “Show hidden files and folders” from the Folder Options in Windows Explorer.

Where is C Documents and Settings folder in Windows 10?

You may find that folder's contents in 'C:\Users\YourUserID\AppData\Local' folder in Windows 10.

How do I find my environment PATH variable?

Select Start, select Control Panel. double click System, and select the Advanced tab. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it.

Which file contains environment variables in Windows?

The Windows System folder. A typical path is C:\Windows\System32. The Windows directory or system root. This corresponds to the %WINDIR% or %SYSTEMROOT% environment variables.


2 Answers

It doesn't exist. Instead, try %USERPROFILE%\..

Warning: as @Mark suggests, this is not reliable because the user profile directory may really be any arbitrary location.

like image 160
tenfour Avatar answered Sep 28 '22 09:09

tenfour


On Vista+ you can use FOLDERID_UserProfiles to get C:\Users (or whatever it may be in localized versions, etc). On XP and earlier you'll pretty much have to go the CSIDL_COMMON_DESKTOPDIRECTORY route that will give you "C:\Documents and Settings\All Users\Desktop" and work your way back from there.

I think this settles it for Vista. For XP the solution is not perfect, but at least it won't depend on the current user's profile path. "All Users" will always exist, and I can't think of a reason for it to be in a place other than the default.

like image 30
martona Avatar answered Sep 28 '22 10:09

martona