0

I tried to use this solution but it is outdated seeing as I use Windows 10 but I was wondering if there is anyway to add a option in the context menu to add a folder to the PATH because it is very annoying to keep modifying the PATH over and over again

3
  • context menu of what (explorer?) and what path (windows environment variable?)?
    – Albin
    Oct 14, 2018 at 21:13
  • Yes Explorer and the environment variable
    – Darth4212
    Oct 15, 2018 at 3:35
  • Adding things to your path makes everything run slower. Every time 'something' is opened and a path isn't provided.. windows has to search each and every one of them for the thing. It may seem convenient.. but it comes at a cost. There is a reason that it isn't quick to do. Apr 17, 2020 at 18:28

1 Answer 1

0

This is already answered in Stackoverflow: https://stackoverflow.com/questions/31269312/adding-a-shell-context-menu-item-so-that-i-can-add-folder-to-path-by-right-click

Managed to find a permanent solution. Since setx sets the user path and not the system path, the command mentioned in my question will add all elements in the combined userpath + system path to PATH, effectively doubling its size every time you run the script.

This can either be fixed by removing user path, or as I did, add another user variable and append that to path. I then ended up with the following script afterwards to set the path correctly:

cmd /k setx UPATH "%%UPATH%%;%1%" && exit

This way I don't need to use a bat-file. Using double %s and &s seem to work as a way to escape the character, thus making it look like this to cmd:

setx UPATH "%UPATH%;drive:/theFolderYouRightClicked" & exit

I am still not sure why you have to pass this through cmd in order to see the PATH-variable, but at least this is a semi-clean way of solving my problem

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .