set environment variables through batch files

G

Guest

I'm setting up some software on a number of PCs where I need to make many
changes to the machines manually. I'm putting this all in a batch file, but
is there a way that I can set an environment variable throught a batch file
so that it is set for every user who logs on to the machine?

I know you can set up user variables through a batch file, I'm just not sure
about environment variables.

Thanks
 
T

Torgeir Bakken \(MVP\)

j-bird said:
I'm setting up some software on a number of PCs where I need to make many
changes to the machines manually. I'm putting this all in a batch file, but
is there a way that I can set an environment variable throught a batch file
so that it is set for every user who logs on to the machine?

I know you can set up user variables through a batch file, I'm just not sure
about environment variables.
Hi

You can e.g use setx.exe for this (using the -m parameter).

For WinXP yo it is included as a utility in the support tools installation
package (on your WinXP CD) installed by suptools.msi.

It is also in the free part of Win2000 Resource Kit:
http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/setx-o.asp

I would think you can use either version on either OS version.


Also note that there is updated versions of Support Tools available:

Windows XP Service Pack 2 Support Tools
http://www.microsoft.com/downloads/details.aspx?FamilyID=49ae8576-9bb9-4126-9761-ba8011fabf38

If you don't have a WinXP CD, or you want to use the latest version of
the tools, it should be ok to install and use the downloadable SP2
version of Support Tools on a WinXP SP1 computer.
 
A

Admiral Q

Too add, if you want these same environment variables the same for all users
on the PC, then set them up as "System Variables" instead of "User
Variables".
 
T

Torgeir Bakken \(MVP\)

Admiral said:
Too add, if you want these same environment variables the same for all users
on the PC, then set them up as "System Variables" instead of "User
Variables".
Hi

The setx.exe's -m parameter that I mentioned does exactly that :)
 
G

Guest

I need to set a system environment variable on 300 or so computers and need a
command line utility to do it. I've looked at the setx.exe utility and it
would seem perfect, except the documentation on MS website (2003 Server
Support Tools) does not match the documentation /? in the tool. Different
switches, etc. namely no /s which allows connection to a remote computer.
What gives?
 
T

Torgeir Bakken \(MVP\)

Chad said:
I need to set a system environment variable on 300 or so computers and need a
command line utility to do it. I've looked at the setx.exe utility and it
would seem perfect, except the documentation on MS website (2003 Server
Support Tools) does not match the documentation /? in the tool. Different
switches, etc. namely no /s which allows connection to a remote computer.
What gives?
Hi

The setx.exe that comes builtin with Win2k3 server supports remote
computers with the /s switch. This functionality does not exist in
the WinXP version.

If you don't have access to a Win2k3 Server, you can do it with
VBScript/WMI instead, using the Win32_Environment class.

Win32_Environment class [WMI]
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_environment.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top