From: Cindy Parker on
Ok, I know. In a batch file I can change environment variables temporarily (=for the
current, remaining session) be entering e.g.

set CLASSPATH=D:\newpath;%CLASSPATH%

However these changes are not visible outside of the current session and furthermore they
are lost after a reboot.

Is there a(nother) way to change them PERMANENTLY from batch script?

I can imagine that there is a way by a regedit or VisualBasic script or 3rd party cmdline tool.

Again: I don't want to edit them manually e.g. in the "System" dialog in control panel.
The change should take place on cmdline from a script

Cindy

From: John John - MVP on
Cindy Parker wrote:
> Ok, I know. In a batch file I can change environment variables temporarily (=for the
> current, remaining session) be entering e.g.
>
> set CLASSPATH=D:\newpath;%CLASSPATH%
>
> However these changes are not visible outside of the current session and furthermore they
> are lost after a reboot.
>
> Is there a(nother) way to change them PERMANENTLY from batch script?
>
> I can imagine that there is a way by a regedit or VisualBasic script or 3rd party cmdline tool.
>
> Again: I don't want to edit them manually e.g. in the "System" dialog in control panel.
> The change should take place on cmdline from a script

Use SetX (a Resource Kit tool).

John
From: John John - MVP on
Cindy Parker wrote:
> Ok, I know. In a batch file I can change environment variables temporarily (=for the
> current, remaining session) be entering e.g.
>
> set CLASSPATH=D:\newpath;%CLASSPATH%
>
> However these changes are not visible outside of the current session and furthermore they
> are lost after a reboot.
>
> Is there a(nother) way to change them PERMANENTLY from batch script?
>
> I can imagine that there is a way by a regedit or VisualBasic script or 3rd party cmdline tool.
>
> Again: I don't want to edit them manually e.g. in the "System" dialog in control panel.
> The change should take place on cmdline from a script

You can use the Resource Kit's SetX for this.

John
From: Marcello on
REG ADD "HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment" /v
MyVar /t REG_SZ /d "Good Morning"

(Restart required.)

Lg
Marcello


From: John John - MVP on
Should be put in the CurrentControlSet, for all we know the
ControlSet001 could be a failed control set... Placing it in the
CurrentControlSet will ensure that it is written to the proper
corresponding nnn Control Set.

John



Marcello wrote:
> REG ADD "HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment" /v
> MyVar /t REG_SZ /d "Good Morning"
>
> (Restart required.)
>
> Lg
> Marcello
>
>