How-To Geek

How to Edit Your System PATH for Easy Command Line Access in Windows

2016-03-24_13h36_57

Have you ever wondered why you can just type ipconfig into a command prompt and it works, but when you want to use a command line program you downloaded you have to navigate to its directory first? Here’s how to fix that using the Windows System PATH.

What Is the Windows System PATH?

If you’ve downloaded a program for the Command Prompt–like ADB, the Android Debugging Bridge–you can’t just type adb in the Command Prompt to run it, like you can with Windows’ built-in commands (e.g. ipconfig ). Instead, you have to tell Command Prompt where to find that file, by typing in the full path of the EXE:

C:\Android\platform-tools\adb.exe

That’s a lot of typing, though, especially for something you have to run often.

The Windows System PATH tells your PC where it can find specific directories that contain executable files. ipconfig.exe, for example, is found in the C:\Windows\System32 directory, which is a part of the system PATH by default. When you type ipconfig into a Command Prompt, Windows doesn’t need to know where that EXE is–it’ll check all the folders in its PATH until it finds the right one.

If you want the same convenience with a program you downloaded (like ADB), you need to add its folder to Windows’ system PATH. That way, when you need to run adb, you can just run:

adb

No extra typing necessary.

How to Add a Folder to Your PATH

The first several steps of the process are the same for Windows 7, 8, and 10. Start by pressing the Windows key to open up the Start Menu or Start Screen, then search for “advanced system settings.” You can alternatively browse through Control Panel to System and Security > System and click on the Advanced system settings hyperlink in the left hand pane.

screenshot.1

Once the System Properties window opens, click on the “Environment Variables” button.

screenshot.2

In the “System Variables” box, look for a variable called Path. Select that and click on the “Edit” button.

screenshot.3

This is where things are different between the versions of Windows—it’s the same for 7 and 8, but slightly different (and easier) in Windows 10.

In Windows 7 and 8

In 7 and 8, the variable value for Path is nothing more than a long string of text with various locations around the system. We’ve put the ADB executables in C:\Android\platform-tools on our machine, so that’s the location we’re going to add.

In order to add an entry to your path in Windows 7 and 8, you have to precede the folder with a semicolon, like so:

;C:\Android\platform-tools

Add that exact line at the end of the variable value (make sure not to delete any of the existing text in the value!) without a space. Click OK, and you’re done. Simple.

screenshot.4

In Windows 10

In Windows 10, this process is both easier and less confusing. Once you’ve clicked the edit button, a new dialog box will appear with each location in the path on a separate line. This is a dramatic improvement over the way previous versions of Windows handled path locations, and makes easy work of adding a new one.

2016-03-24_11h02_18

First, click the ‘new’ button, which will add a line at the end of the list. Add your location— C:\Android\platform-tools in our example—and hit Enter. There is no need to add a semicolon like in Windows 7 and 8. Click the “OK” button and you’re finished.

2016-03-24_11h22_53

The Android Debugging Bridge should now be accessible from any command prompt, no need to specify its directory.

2016-03-24_13h36_57

Cameron Summerson is a self-made geek, Android enthusiast, horror movie fanatic, metalhead, and cyclist. When he's not pounding keys on the 'net, you can find him spending time with his wife and kids, chugging away on the 6-string, spinning on the streets, or watching The Texas Chainsaw Massacre.

  • Published 03/25/16
  • willrun4fun

    in the first example your slashes are the wrong wayC:/Android/platform-tools/adb.exe

    Much nicer in Windows 10 though. Not near as confusing, I like it.

  • Whitson Gordon

    Whoops, that was the editor's fault (me) -_- All fixed!

  • Andrey

    For easy access, I have a folder (eg C:\ bin) that is already included in the path. Then just create and drag shortcuts to executables inside this folder.

    In some cases have to edit the shortcut and type ". \" In the "Start in" field for the application works well.

    To run shortcuts from the command line, just include the extension ".LNK" in the sytem variable "PATHEXT"

  • Frank Sydnor

    I'm on Windows 10 and once I click the edit button after selecting the path variable in System Variables, I get the same dialog box like in Windows 7 & 8. I don't see a newer dialog box with the various paths on a separate line. Is that because I upgraded instead of installed fresh?

  • Cameron Summerson

    That's interesting -- the system I tested this on is an upgraded Windows 10 system. Not sure why you're still getting the old dialog box.

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!