Solved

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

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

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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 68

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 51

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I found out last night windows update has a problem regarding 4 latest updates that fail.  The way to get all 4 them installed is install sp1 first and restart then one by one with a resart in between as they fail every time if all the four updates …
One of the features I've come to appreciate about Windows 7 and Windows Server 2008 R2 is the ability to pin applications to the task bar. As useful a feature as I've found this, it does have some quirks.  For example, have you ever tried pinning an…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now