Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Test Environment Variable
Name: freediver211 Date: May 31, 2007 at 06:58:00 Pacific OS: Windows XP CPU/Ram: N/A Product: N/A
Comment:
Before I attempt to use an environment variable in a DOS batch script I would like to test it to ensure it exist. How do you test an environment variable to ensure it was created?
-------------------- @echo off if "%var%"=="" then goto novar echo Variable VAR does not exist goto end :novar echo Variable VAR = %var% :end --------------------
0
Response Number 2
Name: freediver211 Date: May 31, 2007 at 09:28:10 Pacific
By the way if you are coding to execute in a console window under XP, you can use more powerfull statements in your batch as in XP there is no DOS an what you see at prompt is actually an emulator, the NTVDM (NT Virtual DOS Machine).
So your previous test in XP is coded as
If not defined var ( Do something here...)
where the ( ) enable to code more than one statement.
Post in Programming Forum to get a lot of help from smart people.
Summary: The following sample batch file may help you: @Echo Off :: XPARSE.BAT Sample batch to create an :: environment variable and then parse it :: Type XPARSE EMS to create EMSmyComp :: WARNING it is case ...
Summary: Hello all, I have "imax" environment variables (%file_1%, %file_2%, %file_3%, etc.) pointing to given physical files. In a loop, I want (let's say) to type them one by one. Naively, I was thinking of...
Summary: What is the difference between SET somevar=somevalue and @SET somevar=somevalue Also, does anyone know how to display on the screen the value of a previously set environment variable? many thanks...