Looking for “Add To Path” UI

I’m working with the command line a lot, and I got a lot of different directories in my path. The problem is that I having to edit the path variable in the measly UI in the computer properties sucks.

Is there a good UI for this? A shell extension or an editor?

Print | posted on Saturday, May 27, 2006 2:15 PM

Feedback


Gravatar

#  5/28/2006 3:47 AM Jordi

Hi Ayende,

have you tried to change it from command line ?
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/set.mspx?mfr=true

HTH,
Jordi


Gravatar

#  5/28/2006 5:09 AM Ayende Rahien

@Jordi,
This change is not persistant.


Gravatar

#  5/28/2006 7:34 AM Jordi

Right! But you can also write the changes to the Windows Registry:

How to propagate environment variables to the system
http://support.microsoft.com/?kbid=104011


Gravatar

#  5/28/2006 9:26 AM /\/\o\/\/

As I did see you also use PowerShell before :

[system.environment]::setEnvironmentVariable('path',$env:path + ';c:\PowerShell','machine')
[system.environment]::setEnvironmentVariable('path',$env:path + ';c:\PowerShell','process')

the top one will persist, I do the process one also to make it direct usable in the current shell
and the machine will persist for the next session

(for the machine part you need to re-start the shell.

gr /\/\o\/\/


Gravatar

#  5/28/2006 6:02 PM Ayende Rahien

This looks really cool, thanks.


Gravatar

#  5/28/2006 7:55 PM /\/\o\/\/

Glad you like it ,
to answer the original question to make it a Shell extension :
past this code on the PowerShell prompt, it will add the option to the right click menu of a folder :

New-Item Registry::HKEY_CLASSES_ROOT\folder\shell\Add_to_Path
Set-ItemProperty Registry::HKEY_CLASSES_ROOT\folder\shell\Add_To_Path '(default)' "Add To Path"

New-Item Registry::HKEY_CLASSES_ROOT\folder\shell\Add_to_Path\Command

$Command = @'
"E:\Program Files\Windows PowerShell\v1.0\powershell.exe" -Noninteractive -NoProfile -Command [system.environment]::setEnvironmentVariable('path',$env:path + ';%1','machine')
'@

Set-ItemProperty Registry::HKEY_CLASSES_ROOT\folder\shell\Add_To_Path\command '(default)' $command


the -Noninteractive does not work, so you will see a brief popup of the commandconsole.
but you can add the dir to the path from the exporer.

Enjoy,

Greetings /\/\o\/\/


Gravatar

#  6/3/2006 7:12 AM brian

I don't use PowerShell, but I do love the scripties. I originally found this VBS over at Phil Bogle's site (http://thebogles.com) but it appears that the article has since died.

So here I post the original ZIP containing his work: http://scripteverything.com/files/addtopath.zip.

Usage is simply "addpath [dir]". And there's a /p switch if you wanna prepend to the path list as opposed to the default append.

Comments have been closed on this topic.