2

I am looking for a program for Microsoft Windows 7 that lets the user disables/enables a given path from the PATH environment variable in a convenient way through a GUI. Rapid Environment Editor is great to manage the PATH environment variable but it doesn't have this option to my knowledge (can only add/remove a path).

enter image description here

The feature would be somehow similar to CCleaner's feature to disable/enable a given program at startup:

enter image description here

2

EDIT: Path Manager does not work well at all -> https://superuser.com/questions/891899/issue-when-disabling-a-path-using-path-manager/892798#892798

How about PATH Manager The screenshot shows an "active" column.

  • Did you use that software? Did you like it? What were your experiences? Does that "active" column do what you think it does? – Angelo Fuchs Mar 20 '15 at 14:10
  • 1
    Thanks Jack, the program looks perfect but unfortunately whenever I enable/disable a path I have to either restart the computer, or more simply to go to the he small and inconvenient Windows edit box and click OK there for the change to be taken into account (superuser.com/q/891899/116475) :/ – Franck Dernoncourt Mar 22 '15 at 21:24
1

After some more digging I did still not find a program which does what you want. However, you could create a PowerScript for your purpose. This can be used as starting point:

#requires -version 2

param(
    [string] $AddedFolder,
    [bool] $ApplyImmediately = $true
)

$environmentRegistryKey = 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment'

$oldPath = (Get-ItemProperty -Path $environmentRegistryKey -Name PATH).Path

# See if a new folder has been supplied.

if (!$AddedFolder)
{
    Write-Warning 'No Folder Supplied. $ENV:PATH Unchanged'
    return
}

if ($ENV:PATH | Select-String -SimpleMatch $AddedFolder)
{
    Write-Warning 'Folder already within $ENV:PATH'
    return
}

$newPath = $oldPath + ’;’ + $AddedFolder

Set-ItemProperty -Path $environmentRegistryKey -Name PATH -Value $newPath

if ($ApplyImmediately)
{
    if (-not ("Win32.NativeMethods" -as [Type]))
    {
        # import sendmessagetimeout from win32
        Add-Type -Namespace Win32 -Name NativeMethods -MemberDefinition @"
   [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
   public static extern IntPtr SendMessageTimeout(
       IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam,
       uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);
"@
    }

    $HWND_BROADCAST = [IntPtr] 0xffff;
    $WM_SETTINGCHANGE = 0x1a;
    $result = [UIntPtr]::Zero

    # notify all windows of environment block change
    [Win32.Nativemethods]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [UIntPtr]::Zero, "Environment", 2, 5000, [ref] $result);
}

Source: http://poshcode.org/3537

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.