[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to set an empty environment variable?

Posted on 2000-01-17
18
Medium Priority
?
266 Views
Last Modified: 2013-12-28
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
  • 6
  • 4
  • 4
  • +2
18 Comments
 
LVL 7

Expert Comment

by:sweatbeast
ID: 2360884
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
 

Author Comment

by:Moshe072898
ID: 2361710
I need an empty string, not a space!
0
 
LVL 5

Expert Comment

by:carmine
ID: 2361959
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 12

Expert Comment

by:j2
ID: 2362001
an enviroment variable can NOT be set to a NULL-value.
0
 
LVL 23

Expert Comment

by:Tim Holman
ID: 2362331
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
 

Author Comment

by:Moshe072898
ID: 2362562
I pass some parameter through the environment variable. Sometimes it is empty.
0
 
LVL 12

Expert Comment

by:j2
ID: 2362592
No, it is a whitspace, tab, or some other "unprintable" character.
0
 

Author Comment

by:Moshe072898
ID: 2362693
I meant that a parameter I want pass sometimes is empty.
0
 
LVL 23

Expert Comment

by:Tim Holman
ID: 2362706
Tell us exactly what you're trying to do.
Maybe there's some other way.
0
 
LVL 12

Accepted Solution

by:
j2 earned 300 total points
ID: 2362712
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
 

Author Comment

by:Moshe072898
ID: 2362771
there's an utility called su.exe. I wanted to pass an empty password
0
 
LVL 5

Expert Comment

by:carmine
ID: 2362875
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
 
LVL 5

Expert Comment

by:carmine
ID: 2363195
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
 

Author Comment

by:Moshe072898
ID: 2363512
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
 
LVL 23

Expert Comment

by:Tim Holman
ID: 2363619
Use ""
0
 

Author Comment

by:Moshe072898
ID: 2363660
Where? Set PASSWD = "" doesn't work, that's the whole story!
0
 
LVL 23

Expert Comment

by:Tim Holman
ID: 2363727
set passwd= >nul
0
 
LVL 5

Expert Comment

by:carmine
ID: 2366024
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

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

This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
A few solutions to a problem some of us have been having when trying to add Hostgator email accounts to Outlook 2016 (will probably work with Outlook 2013 as well).
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

612 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