How many times have you needed to add the path of some folder to the PATH Windows environment variable? Ever wished you could just right-click a folder and have the option in the context menu to add it to the PATH variable? How about the added capability of removing PATH variable entries the exact same way? Today is your lucky day. Read on and you’ll be surprised at how easy it is.
If you are a command line junkie like me, you probably want to have all your important tools at your fingertips to launch from the prompt. You also probably keep on adding to your arsenal of such tools by always staying on the lookout for tiny portable apps that make your life on the computer just that little bit easier. Finally, in most likelihood, you don’t want to keep remembering the paths of the folders you have added such tools to, especially if they come in bunches (like Nirsoft or SysInternals suites) and you don’t want to mix them all up in one folder. All of this comes at a cost – fiddling with the PATH variable.
Normally, you would have to manually add these folder paths to the PATH variable. Same is the case when you are getting rid of a bunch of such apps and decide that you no longer need that folder in the PATH variable. Frustrated with having to do it manually each time, I wrote a couple of registry entries to make this task easier by adding ‘AddToPath’ and ‘RemoveFromPath’ entries in the right-click context menus for folders, using which the folder could be directly added to or removed from the PATH variable.
The process basically involves a freeware standalone tool called pathed that is available as a part of gtools by Gerson Kurz. This tiny utility basically lets you manipulate the PATH variable, letting you append entries to it as well as remove existing entries from it, while keeping its formatting intact.
So now that we have a good idea of what we’ll be doing, let’s go ahead and do it.
- Download gtools and install them anywhere on your computer. I keep a C:\PPF folder for all my ‘Portable Program Files’ so I have installed these to C:\PPF\GTools\
Note: The installer only extracts the tools in the installation directory and adds a gtools folder in the Start Menu with shortcuts to the tools, so if you want to keep it all standalone, just delete that Start Menu entry and you’re good to go. We will only be needing the pathed.exe tool, so feel free to delete the rest of the gtools if you don’t need those.
- Download this zip file and extract the contents anywhere on your computer. It contains two registry entry files: AddPathEntries.reg and RemovePathEntries.reg.
- If you have extracted gtools in step 1 to the same path as me (i.e. C:\PPF\GTools\ ), simply double-click AddPathEntries.reg, confirm the prompt that appears, and you’re done. You may skip all the next steps.
- If you have extracted gtools in another folder, right-click the AddPathEntries.reg file and select ‘Edit’ to open it in notepad, or just open it up in any text editor of your choice.
- In the file, you will see C:\\PPF\\GTools\\pathed.exe mentioned twice. Replace both those lines with the correct path of your pathed.exe file, making sure you use double slashes and not single ones. Leave everything else unchanged.
- Once you have edited the file to provide the valid path for pathed.exe, save the file and then double click it, confirming the prompt that you get. That’s it – you’re done.
Once done, simply logout and log back in (or kill and restart all instances of explorer.exe from task manager), and you will see entries for ‘AddToPath’ and ‘RemoveFromPath’ in the context menus of all the folders. You guessed it right – clicking them will add or remove that folder to the PATH variable.
The solution is rather crude at the moment, in that it can possibly lead to clutter in the path variable because duplicate entries can be added for the same folder. However, for now, you can prevent that by always attempting to remove a folder from PATH variable first, before trying to add it. Don’t worry, trying to remove a folder that doesn’t already exist there will not break things in any way.
Oh and if you ever decide that you don’t want these two context menu entries sitting there being evil and all, just run the RemovePathEntries.reg and they’ll be gone. To completely uninstall the whole hack, also delete the gtools folder (or just the pathed.exe file, if you deleted the rest earlier) and there’ll be no traces left. Clean as a whistle, happy as a clam!
Found this hack useful? Don’t forget to let us know in the comments.