Permanently setting environment variables 
Author Message
 Permanently setting environment variables

Winset.exe is actually a Microsoft file, and can be used just as easily with WSH/VBScript.

Winset /?
Sets or removes Windows master environment variables.

WINSET [variable=[string]]

  variable  Specifies the environment-variable name.
  string    Specifies a series of characters to assign to the variable.

I believe it is buried on the Win9x setup CD, but don't have access to one right now to tell the exact path.  You can probably also find it for download at http://www.*-*-*.com/

--

Bill James
Microsoft MVPDTS

?Free Win9x VBScript Utilities?
http://www.*-*-*.com/ ~wgjames/vbspage/

Quote:

> Does WSH and vbscript allow you to set environment variables in the master
> environment?

> Example:

>   Set WshSysEnv = WshShell.Environment("PROCESS")
>  WshSysEnv("FOO") = "MyValue"

> The FOO environment variable is only set until my script stops running.

> I want to change the master environment string.  Kixstart gave you
> Winset.exe to do this.  Before that it was always an undocumented API call
> to get it done.

> Thanks

> Bill Reynen




Mon, 16 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables


Quote:
>Winset.exe is actually a Microsoft file, and can be used just as easily with
>WSH/VBScript.

>Winset /?
>Sets or removes Windows master environment variables.

>WINSET [variable=[string]]

>  variable  Specifies the environment-variable name.
>  string    Specifies a series of characters to assign to the variable.

>I believe it is buried on the Win9x setup CD, but don't have access to one right
>now to tell the exact path.  You can probably also find it for download at
>http://ftpsearch.lycos.com/?form=medium.

I have added alt.msdos.batch* to this thread's newsgroups.
I found %CD%:\admin\apptools\envvars\winset.exe
It does not modify the local environment.
--
Walter Briscoe


Tue, 17 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables

The NT Server Resource Kit has a utility called SETX.EXE that allows you to set the User and System Environment variables from the command line.

SETX variable value: sets the User environment variable
SETX variable value -m: sets the System environment variable.

I am not sure if this utility works on Windows 9x. We are an all NT environment so I have not had the opportunity to try it.
--
Thank you,
Aaron R. Hajduk

Quote:

> Does WSH and vbscript allow you to set environment variables in the master
> environment?

> Example:

>   Set WshSysEnv = WshShell.Environment("PROCESS")
>  WshSysEnv("FOO") = "MyValue"

> The FOO environment variable is only set until my script stops running.

> I want to change the master environment string.  Kixstart gave you
> Winset.exe to do this.  Before that it was always an undocumented API call
> to get it done.

> Thanks

> Bill Reynen




Tue, 17 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
WINSET.EXE does not work in NT 4.0   When I run it on NT I get an error that
WINSET has caused an access violation.

SETX works great in WinNT, but does nothing for Win9x.  Looks like I will
have to sense the environment and run one or the other.

I though WSH was supposed to be so darned useful for Network Admins.  I
can't believe after all these years it's still so darned hard to set an
environment variable!

Thanks to all who replied.

Bill Reynen


Quote:
> Does WSH and vbscript allow you to set environment variables in the master
> environment?

> Example:

>   Set WshSysEnv = WshShell.Environment("PROCESS")
>  WshSysEnv("FOO") = "MyValue"

> The FOO environment variable is only set until my script stops running.

> I want to change the master environment string.  Kixstart gave you
> Winset.exe to do this.  Before that it was always an undocumented API call
> to get it done.

> Thanks

> Bill Reynen




Tue, 17 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
The environment for any VM opened after running Winset will reflect the
modification.  A VM that is already open when winset is run will not.

--
GTS Software Development Services


Quote:


> >Winset.exe is actually a Microsoft file, and can be used just as easily
with
> >WSH/VBScript.

> >Winset /?
> >Sets or removes Windows master environment variables.

> >WINSET [variable=[string]]

> >  variable  Specifies the environment-variable name.
> >  string    Specifies a series of characters to assign to the variable.

> >I believe it is buried on the Win9x setup CD, but don't have access to
one right
> >now to tell the exact path.  You can probably also find it for download
at
> >http://ftpsearch.lycos.com/?form=medium.

> I have added alt.msdos.batch* to this thread's newsgroups.
> I found %CD%:\admin\apptools\envvars\winset.exe
> It does not modify the local environment.
> --
> Walter Briscoe



Tue, 17 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
I use the following code segment for a program called WOLF (Weekly Operating
Load Forecast). It sets the environment variables for all users (system).
You can also use it for the given user ("User") or current process
("Process").

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("System")

WshSysEnv("wolfdbpath")       = "\\ems-nt1\wolf\"
WshSysEnv("wolfdlygenpath")   = "\\ems-nt1\archive\dlygen\"
WshSysEnv("wolftempspath")    = "\\ems-nt1\weather\data\"
WshSysEnv("wolfoutagedbpath") = "\\ems-nt1\atc\"
WshSysEnv("wolftssfilepath")  = "\\ems-nt1\ftp\wolf\tss\"

set WshShell  = Nothing
set WshSysEnv = Nothing


Quote:
> Does WSH and vbscript allow you to set environment variables in the master
> environment?

> Example:

>   Set WshSysEnv = WshShell.Environment("PROCESS")
>  WshSysEnv("FOO") = "MyValue"

> The FOO environment variable is only set until my script stops running.

> I want to change the master environment string.  Kixstart gave you
> Winset.exe to do this.  Before that it was always an undocumented API call
> to get it done.

> Thanks

> Bill Reynen




Tue, 17 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
Re-entrant code is certainly the Grail of any OS. I've never seem any reentrant system that wasn't setting itself up for a fall ( since any extended recursion is doomed in that event, thru exausted resources.)

I'm sure the holy war over a re-entrant OS will contunue in spite of my opinion, however<g>

--
Mark L. Ferguson       Please reply in Newsgroup
marfers notes for OE 5.0  >  http://www.geocities.com/SiliconValley/Bay/6386/IE_ng_notes.htm

Quote:

> WINSET.EXE does not work in NT 4.0   When I run it on NT I get an error that
> WINSET has caused an access violation.

> SETX works great in WinNT, but does nothing for Win9x.  Looks like I will
> have to sense the environment and run one or the other.

> I though WSH was supposed to be so darned useful for Network Admins.  I
> can't believe after all these years it's still so darned hard to set an
> environment variable!

> Thanks to all who replied.

> Bill Reynen



> > Does WSH and vbscript allow you to set environment variables in the master
> > environment?

> > Example:

> >   Set WshSysEnv = WshShell.Environment("PROCESS")
> >  WshSysEnv("FOO") = "MyValue"

> > The FOO environment variable is only set until my script stops running.

> > I want to change the master environment string.  Kixstart gave you
> > Winset.exe to do this.  Before that it was always an undocumented API call
> > to get it done.

> > Thanks

> > Bill Reynen




Tue, 17 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
I noticed this too (through my own trial and error). It's probably good to
mention this where WINSET is recommended in a batch or a solution. Too bad M$
didn't think include this tidbit of info with the syntax output.
Quote:

> The environment for any VM opened after running Winset will reflect the
> modification.  A VM that is already open when winset is run will not.

> --
> GTS Software Development Services





> > >Winset.exe is actually a Microsoft file, and can be used just as easily
> with
> > >WSH/VBScript.

> > >Winset /?
> > >Sets or removes Windows master environment variables.

> > >WINSET [variable=[string]]

> > >  variable  Specifies the environment-variable name.
> > >  string    Specifies a series of characters to assign to the variable.

> > >I believe it is buried on the Win9x setup CD, but don't have access to
> one right
> > >now to tell the exact path.  You can probably also find it for download
> at
> > >http://ftpsearch.lycos.com/?form=medium.

> > I have added alt.msdos.batch* to this thread's newsgroups.
> > I found %CD%:\admin\apptools\envvars\winset.exe
> > It does not modify the local environment.
> > --
> > Walter Briscoe



Tue, 17 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
Huh, I do not follow...  The HELP screen says the MASTER environment, that
is the one which is set when 1st
booted.  So anytime you start a DOS prompt, it is a copy of that
environment.

So, if you run WINSET to set something, you MUST close the window and
restart another, and the environment
variable will be set.

If you want to modify the local environment, use the SET command....


Quote:


> >Winset.exe is actually a Microsoft file, and can be used just as easily
with
> >WSH/VBScript.

> >Winset /?
> >Sets or removes Windows master environment variables.

> >WINSET [variable=[string]]

> >  variable  Specifies the environment-variable name.
> >  string    Specifies a series of characters to assign to the variable.

> >I believe it is buried on the Win9x setup CD, but don't have access to
one right
> >now to tell the exact path.  You can probably also find it for download
at
> >http://ftpsearch.lycos.com/?form=medium.

> I have added alt.msdos.batch* to this thread's newsgroups.
> I found %CD%:\admin\apptools\envvars\winset.exe
> It does not modify the local environment.
> --
> Walter Briscoe



Wed, 18 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
I've also used, as Jim proposes, something like

    wshShell.Environment("SYSTEM").Item(sName) = sNewValue

very often (on 2k/NT) and didn't notice any problem until today. That seems
to work without any problem. If you're trying it out with Cmd.exe (or
Command.com) don't use the set command: It shows only the variables Cmd.exe
found when it was started.

Uwe
----------------


Quote:
> I use the following code segment for a program called WOLF (Weekly
Operating
> Load Forecast). It sets the environment variables for all users (system).
> You can also use it for the given user ("User") or current process
> ("Process").

> Set WshShell = WScript.CreateObject("WScript.Shell")
> Set WshSysEnv = WshShell.Environment("System")

> WshSysEnv("wolfdbpath")       = "\\ems-nt1\wolf\"
> WshSysEnv("wolfdlygenpath")   = "\\ems-nt1\archive\dlygen\"
> WshSysEnv("wolftempspath")    = "\\ems-nt1\weather\data\"
> WshSysEnv("wolfoutagedbpath") = "\\ems-nt1\atc\"
> WshSysEnv("wolftssfilepath")  = "\\ems-nt1\ftp\wolf\tss\"

> set WshShell  = Nothing
> set WshSysEnv = Nothing



> > Does WSH and vbscript allow you to set environment variables in the
master
> > environment?

> > Example:

> >   Set WshSysEnv = WshShell.Environment("PROCESS")
> >  WshSysEnv("FOO") = "MyValue"

> > The FOO environment variable is only set until my script stops running.

> > I want to change the master environment string.  Kixstart gave you
> > Winset.exe to do this.  Before that it was always an undocumented API
call
> > to get it done.

> > Thanks

> > Bill Reynen




Wed, 18 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
That is of course correct.  When a VM is launched a copy of the master
environment is created and a pointer to the environment copy memory location
is set in the (PSP) Program Segment Prefix for that VM.   Changes made
subsequently to the master environment would not affect the copy.

I can certainly see where a less knowledgeable end user might not be aware
of this and might not fully understand the difference between a master and
local environment.  It wouldn't be a bad idea to include a mention of this
in the doc.

--
GTS Software Development Services



Quote:
> Huh, I do not follow...  The HELP screen says the MASTER environment, that
> is the one which is set when 1st
> booted.  So anytime you start a DOS prompt, it is a copy of that
> environment.

> So, if you run WINSET to set something, you MUST close the window and
> restart another, and the environment
> variable will be set.

> If you want to modify the local environment, use the SET command....





> > >Winset.exe is actually a Microsoft file, and can be used just as easily
> with
> > >WSH/VBScript.

> > >Winset /?
> > >Sets or removes Windows master environment variables.

> > >WINSET [variable=[string]]

> > >  variable  Specifies the environment-variable name.
> > >  string    Specifies a series of characters to assign to the variable.

> > >I believe it is buried on the Win9x setup CD, but don't have access to
> one right
> > >now to tell the exact path.  You can probably also find it for download
> at
> > >http://ftpsearch.lycos.com/?form=medium.

> > I have added alt.msdos.batch* to this thread's newsgroups.
> > I found %CD%:\admin\apptools\envvars\winset.exe
> > It does not modify the local environment.
> > --
> > Walter Briscoe



Wed, 18 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
Perhaps this is not strictly on the topic, but one can change the
environment manually in the control panel.


Thu, 26 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
There's no way to address the environment in Control Panel.   Manual changes
to local vars can be made only from a DOS box.  Globals from a DOS box or
run command using Winset.

Greg S.
--
GTS Software Development Services



Quote:
> Perhaps this is not strictly on the topic, but one can change the
> environment manually in the control panel.



Fri, 27 Sep 2002 03:00:00 GMT  
 Permanently setting environment variables
I believe the question was how to permanently change the environment, which
would not exactly be changes to local vars.
Changes to the local environment are made with the SET command.
The control panel "System" applet, "Environment" tab allows you to change
the global environment.

What that means is that there must be a [dangerous] way to run a .reg or
.inf file from the console to update the persistent environment settings in
the registry.

If the changes are for the next session of the computer, one's batch program
can edit autoexec.bat.


Quote:
> There's no way to address the environment in Control Panel.   Manual
changes
> to local vars can be made only from a DOS box.  Globals from a DOS box or
> run command using Winset.

> Greg S.
> --
> GTS Software Development Services



> > Perhaps this is not strictly on the topic, but one can change the
> > environment manually in the control panel.



Sat, 28 Sep 2002 03:00:00 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. How to set a DOS environment variable

2. How do SET a DOS environment variable

3. How set an environment variable with vbscript?

4. Set environment variable and lcaunch an application

5. How do I set an environment variable?

6. Setting environment Variables via VB Script

7. Setting System Environment Variables

8. how can I set an environment variable in vbscript

9. setting an environment variable

10. setting an environment variable

11. Setting Citrix environment variables

12. Setting environment variables

 

 
Powered by phpBB® Forum Software