Solved

How to set system variables using windows batch file.

Posted on 2011-03-23
7
804 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
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 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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
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.
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

751 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