Solved

How to set system variables using windows batch file.

Posted on 2011-03-23
7
810 Views
Last Modified: 2012-05-11
We have a Windows CAD program that looks to the System Variables under the Environmental Variables to find the location of it's configuration information.  Sometimes we need to use 2 sets of configuration information and right now that would require going into Environmental Variables and changing the System Variables each time.  I had thought about using a batch file to set the System Variable and then launch the CAD program but I wasn't sure if this would work.  I would then have a batch file they could run after to set them back to the original System Variables.  Any help and ideas are appreciated.
0
Comment
Question by:jwiang4u
[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
  • 4
  • 3
7 Comments
 
LVL 12

Expert Comment

by:silverkorn
ID: 35199004
is there a way to define what system variables the CAD program is looking for?

this way you could create two sets of the variables once and not need to change it. The problem with changing the system variable is having the user changing it back to use the first CAD program.
0
 
LVL 1

Author Comment

by:jwiang4u
ID: 35199068
There is no way to define what system variable the CAD program is going to use apart from the default, unfortunately.
0
 
LVL 12

Expert Comment

by:silverkorn
ID: 35199092
does the system variable need to be established prior to the start of the program or can you change the variable once the program has loaded?
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 1

Author Comment

by:jwiang4u
ID: 35199119
It has to be prior to the start of the program because the configuration folder contents are read while the program is starting.
0
 
LVL 12

Expert Comment

by:silverkorn
ID: 35199189
then it appears that your assumption is correct on changing the system variables with the batch file prior to the start of the program.

here is how to change the variables through the batch file:
http://support.microsoft.com/kb/121170

also make sure to have the batch file check to see what the variable is prior to changing it, this way if the variable is set correctly it then starts the program

the other option is to have the batch file ask the user which version they wish to run, this way you then only have one batch file to create and for the user to run.

let me know if you need help creating the batch file itself
0
 
LVL 1

Author Comment

by:jwiang4u
ID: 35199387
Thanks for the info.  I am trying to set the System Variable using the following MS link:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true

I did notice the following in the article which makes me a little worried:
"The set command alters variables in the current shell environment only."

Does this mean that once the batch file sets the variable and starts the program, the set variable goes away?  Does the program that is launched get this variable?
0
 
LVL 12

Accepted Solution

by:
silverkorn earned 500 total points
ID: 35199461
For Windowx XP you can use the SETX command to change the variables as detailed here:
http://technet.microsoft.com/en-us/library/cc755104(WS.10).aspx

to get the command you can download it here:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=49ae8576-9bb9-4126-9761-ba8011fabf38&displaylang=en
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
A small collection of useful tips and tricks for Windows 10 users that I decided to write as a result of recent questions that were asked and answered at Experts Exchange. Two short video tutorials included. Enjoy..
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

623 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