Solved

How to set system variables using windows batch file.

Posted on 2011-03-23
7
798 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
  • 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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.

706 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

19 Experts available now in Live!

Get 1:1 Help Now