Solved

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

Posted on 2010-11-08
10
623 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

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.

Question has a verified solution.

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

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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.

808 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