[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2010-11-08
10
Medium Priority
?
627 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 21

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 57

Accepted Solution

by:
Bill Prew earned 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Expert Comment

by:netcmh
ID: 34086916
I concur with billprew: http://ss64.com/nt/setx.html
0
 
LVL 14
ID: 34089338
I agree, Bill Prew's Answer is the correct one.
0
 
LVL 71

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 21

Expert Comment

by:netcmh
ID: 34092615
good point
0
 
LVL 57

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 14
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

649 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