August 18, 2019, 03:52:58 pm


IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!

Understanding the windows registry - Paths and variables

Started by Andy, November 11, 2016, 06:32:46 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


For this tutorial, I will show you where certain user and system wide paths are stored and how they are used.

It is perfectly safe to view these keys / values BUT do not change any of the keys / values mentioned in this tutorial!

Open Regedit.exe to follow this tutorial.

Registry paths and variables.

Some registry entries have the % symbol surrounding them, e.g. %USERPROFILE%, and depending on the user, the value of %USERPROFILE% will change.

So let's start with the current user.....

The key:
HKEY_CURRENT_USER is just a sub-folder of
where  S-1-5-21-3810301207-286795136-547885110-1000 relates to (in this case) the current user's hive.

What does that mean?
It means if you change a registry setting in HKEY_CURRENT_USER it will also change in
HKEY_USERS\S-1-5-21-3810301207-286795136-547885110-1000 and vice versa.

A second user's hive (on creation of a new user) usually just increments this number so they are all individual.

That is for Andy it's  S-1-5-21-3810301207-286795136-547885110-1000
and for Anne it's       S-1-5-21-3810301207-286795136-547885110-1001 … and so on....

So that said, where are the locations for a logged on user's documents, pictures, files set?

They are set here:
HKEY_CURRENT_USER\Volatile Environment   (fills you with confidence!)

It contains string entries like this:
USERNAME         stores a value such as Andy
USERPROFILE      stores a value such as C:\Users\Andy

The value of USERNAME for example could be used to customise a messagebox e.g.
“Andy, or you sure you want to exit?” - this is exactly what the GetUserName function does â€" i.e. reads this registry entry and returns it's value.

These specific entries we can think of as variables and are referenced by other sections of the registry like this string called Path, located in HKEY_CURRENT_USER:

Path     value could be    %USERPROFILE%\AppData\Local\Microsoft\WindowsApps

As mentioned before, the value of %USERPROFILE% on my machine could be C:\Users\Andy or C:\Users\Anne, this is handy when you don't know the user's profile path but don't want to change the rest of the string value.

As there can only be one user for the current user (the one you are using), HKEY_CURRENT_USER uses the % variables, which change as one user logs out and another one in.  It's the same for when you switch users too.

In XP:-  C:\Users\Andy would be  C:\Documents and Settings\Andy

A note about the name “hive”, it seems it's an old MS joke from one developer to another. One developer apparently hated bees, so the other started to call user folder's “hives”, true or not?, who knows. 

Now for the computer including all users...

Keys of note for this are:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

There is a string entry here called SystemRoot.

SystemRoot would typically have a value of C:\Windows, which gives the location of your windows path.

It may be used by other registry strings as %SystemRoot%.

The other main variable used is %SystemDrive%,
i.e. C (The C:\ drive).

To obtain this, %SystemDrive% takes the first letter of %SystemRoot%

SystemRoot = C:\Windows so, %SystemDrive% = C

So, the use of these registry variables could be of use for you, especially %USERPROFILE%.

I hope you've found this of interest, and not boring!


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.