?
Solved

How to "set" an empty environment variable?

Posted on 2000-01-17
11
Medium Priority
?
332 Views
Last Modified: 2013-12-29
I need to set an environment variable with an empty value. How do I do it ( in a batch file) ?
0
Comment
Question by:Moshe072898
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 2

Expert Comment

by:jedimike
ID: 2361044
if you set temp to nothing, it disappears.
0
 

Author Comment

by:Moshe072898
ID: 2361714
I know, I need to overcome this!
0
 
LVL 50

Expert Comment

by:dbrunton
ID: 2361844
Try this in Dos.  It may not be what you want

Set bill=gates

Set

and type set and you should see of course

bill=gates

Now

set bill=

(but prsss the spacebar after the equal sign before you press Enter)

and type set again and you will see

bill=

but of course bill is equal to the spacebar whick may not be what you want.
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
LVL 12

Accepted Solution

by:
j2 earned 300 total points
ID: 2361997
en enviroment variable cannot have a NULL value, so either you set it to "space" like dbruntso suggests, or else you cannot do this.
0
 
LVL 12

Expert Comment

by:j2
ID: 2361998
gah.. i meant that as a comment
0
 

Author Comment

by:Moshe072898
ID: 2362549
Is it specified somewhere that a environment variable can not have an empty string value?
0
 
LVL 12

Expert Comment

by:j2
ID: 2362598
Yes, Every dos programmers manual since version 1.0 or so.
0
 
LVL 12

Expert Comment

by:j2
ID: 2362620
Lets reason here.

A enviroment variable can contain either "something" or "nothing" right?

When an enviroment variable contains "Nothing" it is removed from the enviroment.

Simple, huh? :)
0
 

Author Comment

by:Moshe072898
ID: 2362721
Well, if the things are like that I don't see a way out here.
0
 
LVL 50

Expert Comment

by:dbrunton
ID: 2365940
I am going to say that there is a way to do it.

Because the environment variable is removed we test for the environment variable.

Try the following batch file.

if "%temp%"=="C:\WINDOWS\TEMP" goto one
echo This is one
:one
if "%first%"==" " goto two
echo This is two
:two
if "%first%"=="" goto end
echo This is three
:end

If you do not have an envrionment variable set for first then you will not see the message This is three.
0
 

Author Comment

by:Moshe072898
ID: 2366215
Ye, is's easy to define if a variable exists. But I need to PASS AN EMPTY STRING using an environment variable!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
MS Outlook undoubtedly is the most widely used email client.Its user-friendliness, cost effectiveness, and availability with Microsoft Office Suite make it the most popular email application.  Its compatibility with Microsoft applications like Exch…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

599 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