Solved

How to set system variables using windows batch file.

Posted on 2011-03-23
7
803 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
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
save browser passwords 11 72
Problem to file 4 28
Windows 10 taskbar - how to display labels with icons 4 81
LOGINSERVER and nltest /dsgetdc 3 40
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
An article on effective troubleshooting
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

830 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