Wednesday, July 18, 2007

Managing System Environment Variable

OS: Windows 2000 or higher

System Environment Variables can be managed using one of the ways below

1. Start->Control Panel-> System->Under Advanced tab->Click Environment Variables button->Add, modify, delete system or user variables by clicking New, Edit or Delete buttons respectively . Reboot the system for changes to take an Effect.

2. System Environment Variables can be managed by making changes to the registry key Below

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment

  • Run command->regedit
  • Browse to the above registry key
  • Add Variable -> Create a New Value under this Key
  • Modify Variable-> Modify Value if it already exists under this key
  • Delete Variable -> Delete a registry value for the variable

    Modifying registry requires a reboot for changes to take an effect

3. SetEnv command can be used to manage system environment variables and avoid reboot

Download a free tool at link below

http://www.codeproject.com/tools/SetEnv.asp

  • Add or modify a system variable
    SetEnv –a [VARIABLENAME ] [VARIABLEVALUE]

  • Add to a variable with multiple values, prefix value with % character
    SetEnv –a [VARIABLENAME ] %[VARIABLEVALUE]

  • Add User Variable
    SetEnv –ua [VARIABLENAME ] [VARIABLEVALUE]

  • Deleting a variable
    SetEnv –d [VARIABLENAME ] [VARIABLEVALUE]

  • Deleting a value from multiple value variable
    SetEnv –d [VARIABLENAME ] %[VARIABLEVALUE]

  • Deleting a user variable
    SetEnv –ud [VARIABLENAME ] [VARIABLEVALUE]

____________________________