A few weeks ago we showed you a handy shortcut to quickly access the environment variables on your machine:

 

Tip of the Week: Directly Access Environment Variables With a Shortcut.

 

This week we'll explore a related topic of how to change the environment for a single program session on Windows, via a simple batch script.

 

Two examples of why you might want to tailor the environment for a single session, each followed by a sample two-line script:

 

Example #1:

You want to change the MGLS_LICENSE_FILE to point to a different license server (1717@MyDxDserver) when you launch only DxDesigner, and have all your other Mentor applications use the current value that is stored in the environment variable.


Batch script example (make sure the file ends in ".bat" otherwise it won't execute when you run it):

 

set MGLS_LICENSE_FILE=1717@MyDxDserver
start C:\MentorGraphics\9.5PADS\SDD_HOME\wv\win32\bin\viewdraw.exe

 

When you double-click on the .bat (batch) file the MGLS_LICENSE_FILE environment variable gets changed to 1717@MyDxDserver but ONLY for DxDesigner. No other applications are affected by this change.

 

Notes:

- The "start" keyword means the DOS window goes away as soon as the application appears. You can remove the keyword but then the prompt stays up until you close the application.
- To get the path to "viewdraw.exe" you can right click on the DxDesigner shortcut and copy and paste the "target" field.
- If you want the script to work regardless of which version you are configured for, you can reference the %SDD_HOME% environment variable instead of using an absolute path. In this case you would substitute the second line with "start  %SDD_HOME%\wv\win32\bin\viewdraw.exe". In the 2nd example below we use the %SDD_HOME%.

 

Example #2:

You're running into a DLL conflict between DxDesigner and an application from another software vendor. You want to reduce the PATH variable used by DxDesigner to only the system values plus the required Mentor Graphics folders, while keeping the PATH value the same for all other applications.

 

Batch script example (make sure the file ends in ".bat" otherwise it won't execute when you run it):

 

set PATH=%SDD_HOME%\common\win32\bin;%SDD_HOME%\common\win32\lib;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%MGC_HOME%/bin;%MGC_HOME%/lib

start %SDD_HOME%\wv\win32\bin\viewdraw.exe