Windows 10 Environment Variables

In Windows 10, the first 5 letters of your email are used to create a local folder on the system drive.

In my case this is C:\Users\Phili

This will be different in your case, meaning if you copy and paste the file location given it won't find anything on your computer.

There are a number of environment variables in Windows 10 which can be used to access each user location. They can be copied and pasted into the address bar:

For example %UserProfile%

Which in my case takes me to C:\Users\Phili and in your case will take you to your User Profile:

Local User Environment Variables

This can also be used to access commonly used libraries:


OneDrive Environment Variables

Note if the Documents, Pictures, Music and Desktop folders are fully integrated with OneDrive you can use:


Public User Environment Variables

In a Windows 10 installation the permissions of each User Folder is locked to the specific user. A second user account on the computer generally cannot access the documents of the first user and vice-versa. To overcome this, there is the Public users folder. The public folder can optionally be shared across the network:


Other Common Folders Environment Variables

Other commonly accessed locations by programs are the Roaming AppData folder, the Local AppData folder, the Temporary folder, the ProgramFiles folder, the CommonProgramFiles folder, the ProgramData Folder and the Start Menu shortcuts:

%ProgramFiles%C:\Program Files
%ProgramFiles(x86)%C:\Program Files (x86)
%CommonProgramFiles% C:\Program Files\Common Files
%CommonProgramFiles(x86)%C:\Program Files (x86)\Common Files
%ProgramData% C:\ProgramData
%AppData%\Microsoft\Windows\Start Menu\Programs\StartupC:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
%SystemDrive% C:\

Creating a Custom Environment Variable

Right click the Start Button and select System:

Scroll down and select Advanced System Settings:

Select Environment Variables:

Select New:

Create a Variable Name (without denoting the %) and specify a Variable Name (the Location of the folder). Select OK and OK on the Environment Variables Window.

You can now use your new Environment Variable:

This will take you to the folder specified:

In Python the environment variables can be accessed by use of the os library. The environ attribute acts as a dictionary and the key is the Environment Variable. For example in the case of %UserProfile%

import os

The User Profile location is returned as a strong. Recall that \ is denotes a special character is to be displayed as part of a string in Python and \\ means to display a single \

This difference can be seen when the print statement is used.

To get the documents folder string concatenation can be used:


Recall that r before a string denotes a relative string. When this is used one can type in the folder location as \Documents opposed to \\Documents. The \ should be used before the folder.

If a file is included the \ should be included by the file name and extension. For example: