In this blog we’ll be covering how to add a directory to the Windows path variable.
Windows uses the path variable as a pointer to the directories it needs to search when looking for programs. A program for a Windows computer is simply a set of instructions compiled into an executable file identified with the “.exe” extension
In Windows, when we click on an icon to open a program, (usually a shortcut), the icon will have the path to the executable (or .exe) for the program, associated with it.
If there is no shortcut for the program, for instance when you’ve copied an executable that doesn’t need installing, it won’t have a pointer in the PATH variable.
So to access that program you can either create a shortcut for
Finding the path to a Windows Program
1; If you know which folder the “.exe” file is in you can simply browse to the location and left click with the mouse in the browser bar at the top of the file explorer window and you’ll see the path as below.
2; Select the text by left-clicking in the browser bar then holding and dragging the mouse across the text until all of it is blue, then right-click the text and select copy from the pop-up. You can paste the copied text into the path variable in a later step.
3; Another way of finding the executable is to open the command prompt. You can do that by clicking the Windows Start button, then typing “cmd” in the search bar and finally clicking on the “Command Prompt” icon in the list shown.
4; Once the command window is open type in “where” and press the return (or Enter) key. This will show the help for the “where” command.
5; We want a command similar to the one outlined in red above. If we were looking for openssl.exe, then we’d need to type in, “where /R c:\ openssl.exe” so we’re recursively (/R) searching from the root directory (c:\) for the pattern “openssl.exe”.
6; In the command prompt you can highlight the path as far as the directory “c:\Program Files (x86)\GnuWin32\bin” and then right-click to copy it in preparation for adding it to the PATH variable.
Adding the directory to the PATH variable
7; Since we’ve got the command prompt open already, we can simply type “path” and press return to see the current value of the PATH variable.
Since our program isn’t in any of the directories shown in the PATH variable and we are not in the same directory as openssl.exe, typing “openssl.exe” produces an error, because the Windows system can’t find the program.
8; We can add our new directory to the PATH variable within the Command Prompt window, but first type “path /?” and press return to see the path help.
9; So, we need to be aware that typing “path” followed by our new directory and nothing else will result in removing all the other path variables. Entering “path C:\Program Files (x86)\GnuWin32\bin” will leave us with;
PATH=C:\Program Files (x86)\GnuWin32\bin
10; So to keep the existing path we need to include %PATH% in the command as follows C:\Users\user>path %PATH%C:\Program Files (x86)\GnuWin32\bin.
Now when we type the name of our program, “openssl.exe” it runs the program instead of showing the error.
Checking the PATH variable with the GUI in Windows 10
11; We can also check and amend the path variable with the GUI. To access from Windows 10, click the start button and then click Settings.
12; From the next screen type path in the search box and then select “Edit the system environment variables”.
13; Next, select the Environment Variables button from the Advanced tab of the System Properties dialogue.
14; From the Environment Variables window, either double click the System Variables Path or select it and click on the Edit button. This will bring up the “Edit environment variable window” where you can edit, change the order of, or add and delete entries.
Checking the PATH variable with the GUI in Windows 7
15; On the desktop, right-click the My Computer icon and choose Properties.
16; You’ll then be presented with the System Properties dialogue similar to Windows 10 in step 13 above. Select the Environment Variables button from the Advanced tab.
17; You’ll then see an Environment Variables window and you can double click the Path variable or select it and click edit the same as for Windows 10.
To cut a long story short, the summary
There are occasions when working with Windows that some programs will require you to either start them or use them from the Command Prompt. You’ll either need to be in the same directory as the executable file to start the program, or you’ll need to add the directory where the program resides, to the PATH system variable of Windows.
You can do this either within the Command Prompt itself, or navigate to a GUI or Graphical User Interface.
We covered the steps to use the Command Prompt and
If you’re a network engineer and you could use an IPv4 subnet calculator check out the free techiedoodah IPv4 excel subnet calculator spreadsheet and if you get a lot of time hands on rackside and need a tray to put your laptop on, let us know what you think of the Portable Rack Mount Laptop Tray and sign up if you want one. Type with two hands instead of one, be more comfortable, improve your productivity and get out of the server room sooner, (or wherever the rack happens to be).
Techiedoodah blogs are created in the hope that they can help others by giving real-life examples. If this has been useful to you please feel free to leave a comment. If you’re reading this post on the home page, you won’t be able to post comments here, so follow this link to the blog, and then scroll to the comments section at the bottom of the page.
Comments for How to add a directory to the Windows path variable.