Different Ways to Add a Folder to System PATH Variable in Windows

Many of the popular programs (especially the command line programs) require that you add the folder where they are located to the system PATH variable for the proper functioning. For example, the TDM-GCC compiler can be installed on your Windows PC but it will not work properly without adding it to the PATH variable. Exactly same can be said about Python interpreter, FFmpeg tools, and many other very popular programs.

Usually, the setup installers for these programs can handle adding the program folder to the system PATH variable. But you can also do this manually in a number of ways:

1. Using SETX command

If you want to add a folder C:\GCC\BIN to the PATH variable, then you can open an elevated command prompt and give the following command:

setx path "%PATH%;C:\GCC\BIN" /M

Notice the switch /M is used in this command to make sure that the PATH variable for the entire machine is used. If you omit this switch, then it will add the folder to the user’s PATH variable.

2. Using Windows Registry Editor

All the environment variables are stored in the Registry, so you can directly edit these values in the Registry and change them or add new folders to the PATH variable. In order to do this, you have to open the Windows Registry Editor and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment.

Add Any Folder to System PATH Variable

On the right-side, you will find the PATH variable that you can double-click on and edit it. When editing, make sure that you append a semi-colon to the end before adding a new folder.

3. Using System Properties

This is the method that perhaps everybody knows about. But it should be listed to make the list of methods complete. Basically, you open the Windows system properties by pressing the hotkey Win + Pause. In the system properties window, click on the Advanced system settings. In the window that opens, click on the button labeled Environment Variables.

Add Any Folder to System PATH Variable

The window that is displayed next allows you to view, add or edit the various environment variables both for the current user and the entire machine. You can select PATH from the lower list and click on the Edit button to add new folder path to this variable.