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.

sweatbeastCommented:
I am not sure you can set an environment variable as a null, but you can set it to space.
Just SET variable_name= (thats a space) should do. Bung that into a batch file,
0
Moshe072898Author Commented:
I need an empty string, not a space!
0
carmineCommented:
Acn't be done afaik, you either have the variable (with a value) or you don't.  Why do you need a null value?

Mark
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:
an enviroment variable can NOT be set to a NULL-value.
0
Tim HolmanCommented:
SET only works with a string.
Nothing isn't a string.
Well.  Literally, I suppose it is, but what I mean to say is you can't have nothing in a string, as it wouldn't be a string, it would just be nothing, and if you want nothing, you may as well not even bother having a variable for it.
What do you need it for ?
Silly question - I mean - what do you need nothing for ?
0
Moshe072898Author Commented:
I pass some parameter through the environment variable. Sometimes it is empty.
0
j2Commented:
No, it is a whitspace, tab, or some other "unprintable" character.
0
Moshe072898Author Commented:
I meant that a parameter I want pass sometimes is empty.
0
Tim HolmanCommented:
Tell us exactly what you're trying to do.
Maybe there's some other way.
0
j2Commented:
Then you have to make sure it _isnt_ empty. There are no two ways about this. An empty variable is removed from the enviroment.
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
Moshe072898Author Commented:
there's an utility called su.exe. I wanted to pass an empty password
0
carmineCommented:
Wrap a batch file around it. something like (I've not looked up the su syntax:

if defined pswd (su -u%user% -p%pswd%) else (su -u%user%)


Mark
0
carmineCommented:
Wrap a batch file around it. something like (I've not looked up the su syntax:

if defined pswd (su -u%user% -p%pswd%) else (su -u%user%)


Mark
0
Moshe072898Author Commented:
The whole point is to feed a su with the empty password (in a batch, of course) . If I don't specify passowrd at all, it asks for it interactively and that's I want to avoid.
0
Tim HolmanCommented:
Use ""
0
Moshe072898Author Commented:
Where? Set PASSWD = "" doesn't work, that's the whole story!
0
Tim HolmanCommented:
set passwd= >nul
0
carmineCommented:
So why can't you use something like:

su -u:%username% -p:""

It would be a BIG help if you could show us the batch you are trying to use!

Mark
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.