How to "set" an empty environment variable?

I need to set an environment variable with an empty value. How do I do it ( in a batch file) ?
Moshe072898Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jedimikeCommented:
if you set temp to nothing, it disappears.
0
Moshe072898Author Commented:
I know, I need to overcome this!
0
dbruntonCommented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

j2Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
j2Commented:
gah.. i meant that as a comment
0
Moshe072898Author Commented:
Is it specified somewhere that a environment variable can not have an empty string value?
0
j2Commented:
Yes, Every dos programmers manual since version 1.0 or so.
0
j2Commented:
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
Moshe072898Author Commented:
Well, if the things are like that I don't see a way out here.
0
dbruntonCommented:
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
Moshe072898Author Commented:
Ye, is's easy to define if a variable exists. But I need to PASS AN EMPTY STRING using an environment variable!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.