Solved

How to set environmental variables in Windows 7 using a batch file ?

Posted on 2010-11-08
10
622 Views
Last Modified: 2012-05-10

I have a Windows 7 PC and I wanted to set the environmental variables.

I know I can right click on MYCOMPUTER=> Advanced tab and set there SYSTEM EV.

But instead of doing that I wanted to write a windows batch file (.BAT) and do it.

How can I do that.

If i go to command line and use the SET command , is it only for that particular session, once we close and reopen another session the EV are no longer there.

I wanted to set the EV permanent, same way as what we do using GUI, but using a windows batch file (.bat).

Give me the commands or some sample script

Thanks in advance
0
Comment
Question by:OCUBE
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 20

Expert Comment

by:netcmh
ID: 34086232
0
 

Author Comment

by:OCUBE
ID: 34086286


All  need to know is the command to setup the EV in command prompt and it should
be permanent, not just for that session.


0
 
LVL 53

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 34086884
You can do this with the SETX command from the command line.

http://technet.microsoft.com/en-us/library/cc755104%28WS.10%29.aspx

~bp
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 20

Expert Comment

by:netcmh
ID: 34086916
I concur with billprew: http://ss64.com/nt/setx.html
0
 
LVL 11

Expert Comment

by:Ben Personick
ID: 34089338
I agree, Bill Prew's Answer is the correct one.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 34091030
AFAIK there is still a difference between the GUI and setx: setx will not inform open Windows about the change. Usually that does not matter, since most applications ignore the change anyways until restarted, but sometimes it is important to know that.
0
 
LVL 20

Expert Comment

by:netcmh
ID: 34092615
good point
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34092667
Well, there are some subtleties there, right.  For instance, if I set a system variable from the GUI, but had a command shell window open, that command shell doesn't see that new environment variable.

~bp
0
 
LVL 11

Expert Comment

by:Ben Personick
ID: 34092813
Agreed - on both Qlemo and BP's accounts there.. Though, I did think SETX had the same drawback with open windows as via GUI for other command windows, but haven't tested, I believe BP to know his stuff.

  Still, I imagine SETX wins out because he asked "From the Command Line", but as always; the author's true intentions for implementation may allow for the GUI method, or perhaps prefer it.

~Q
0
 

Author Closing Comment

by:OCUBE
ID: 34094679

Thanks
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no backā€¦
On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question