user146043
user146043

Reputation:

Forcing environment variable changes to take effect immediately

I need to change the value of the Cygwin environment variable CYGWIN on one of my installs from:

ntsec tty 

back to the default value of:

ntsec notty

I can do this programmatically via a .reg file:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
"CYGWIN"="ntsec notty"

but it doesn't affect current or subsequent command prompts until a reboot. I don't want to have to reboot! Is there any way I can force this change to apply to, at the very least, subsequent command prompts, immediately?

Upvotes: 5

Views: 8250

Answers (1)

dch
dch

Reputation: 1542

This is very easy to fix & you shouldn't kill explorer to do it. TL;DR use:

setx.exe var value

to make changes available in future command windows, and in all active windows processes that support WM_CHANGESETTINGS API. You can do this for system environment vars as well, which will be propagated to services that support this API.

This doesn't change the current CMD.exe or cygwin shell as neither of them support it.

In those the humble set var=value or export var=value will need to be done once per shell.

http://support.microsoft.com/kb/104011 for more info.

A+ Dave

Upvotes: 8

Related Questions