Often at work I have to install new frameworks etc which do not add themselves to path and I have to go through the tedious process of adding the exectuables to path. I therefore decided to add a shell context menu item so that I can add any given folder to the path just by right clicking it and selecting "add to path".
I went through the normal routine of creating a context menu item and I used the following command to add the folder to path:
setx PATH "%PATH%;%1%"
This seems to not evaluate the PATH-variable, and instead replaces my PATH with something like this:
PATH;C:\Program Files (x86)\Android\android-sdk\platform-tools
Is there a way to make the context menu item evaluate %PATH% instead of just ignoring the percentage signs? I've read about using \,^ and just adding an additional % but none of these approaches seem to work.
In case it matters, this is on a Windows 7 Enterprise computer
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