Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

check if environment variable exists

2,071 views
Skip to first unread message

Andreas Moroder

unread,
Sep 24, 2007, 9:09:44 AM9/24/07
to
Hello,

is there a way to check in a .bat file if a certain environemnt variable
exists ?

if exists %myvar% echo yes

does not work.

Bye
Andreas

billious

unread,
Sep 24, 2007, 10:07:35 AM9/24/07
to

"Andreas Moroder" <Andreas.moroder@[nospam]sb-brixen.it> wrote in message
news:fd8g4t$6jt$1...@news.dtag.de...

Depends on the OS version you are using.

Since you are posting from XP,

if defined varname ...

is probably best, although

if not "%varname%"=="" ...

should work for DOS/9x

NT+ questions are better placed in alt.msdos.batch.nt as DOS/9x and NT
methods differ greatly.


Gerard Bok

unread,
Sep 24, 2007, 10:34:18 AM9/24/07
to
On Mon, 24 Sep 2007 15:09:44 +0200, Andreas Moroder
<Andreas.moroder@[nospam]sb-brixen.it> wrote:

>is there a way to check in a .bat file if a certain environemnt variable
>exists ?
>
>if exists %myvar% echo yes

if N%myvar%==N echo no

You work out the other way around :-)

--
Kind regards,
Gerard Bok

0 new messages