Setx Environment Variables

By default setx sets the variable in the local environment (Under HKEY_Current_User Registry key). If you want to set the system variable (Under HKEY_LOCAL_MACHINE registry key), use the flag /m.

The set command only sets the environment variable for the current session. The setx command sets it permanently, but not for the current session. If you want to set it for current as well as future sessions, use both setx and set.



SETX /M CLASSPATH .;C:\IBM\SQLLIB\java\;C:\IBM\SQLLIB\java\db2jcc.jar;C:\IBM\SQLLIB\java\db2cc_license_cu.jar;C:\IBM\SQLLIB\bin;C:\IBM\SQLLIB\java\common.jar

Append to Path use %PATH%

SETX /M PATH “%PATH%;X:\win32\install\bin;X:\win32\install\core\CO_ORBIX\bin;X:\win32\install\core\CO_JDK\bin”

Set environment variable by Registry edit

If your PATH variable is too long, then the best method would be to edit the registry.

For user environment variables, change the key HKEY_CURRENT_USER\Environment. For System Environment variables change

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Add, Edit or Delete the environment variable you want to change, then reboot to activate the changes.

Leave a Reply

Your email address will not be published. Required fields are marked *