From: e-mail DOT address AT end DOT of DOT text (Mike Collins) Newsgroups: comp.os.msdos.djgpp Subject: Re: How to read/modify environment variables? Date: 25 Jun 1997 09:39:48 GMT Organization: Storage Technology Limited Lines: 39 Message-ID: <5oqp14$9i0@news.network.com> References: <33B013CC DOT E452725B AT po DOT uni-stuttgart DOT de> NNTP-Posting-Host: 129.80.172.76 Mime-Version: 1.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article <33B013CC DOT E452725B AT po DOT uni-stuttgart DOT de>, Martin DOT Bernreuther AT po DOT uni-stuttgart DOT de says... > >Hi, > >I like to write a small tool to add a path to the PATH variable >only if it's not already in. >How can I get a hold of the environment variables? >Is there already a tool to do this? >Is there maybe a tool just to search a environment variable for >a string? > I know how to do it in a batch program, though it doesn't have much to do with DJGPP! eg TEST.BAT if %ABC%=XYZ goto ALREADY_DONE SET ABC=XYZ ECHO I just set the environment variable REM do other stuff too if you want goto END :ALREADY_DONE ECHO The environment variable was already set. :END It's cumbersome and there's probably a more elegant way, but you could try using a 'system' statement (I have not tried this, and I don't even know if it works outside of a batch file) system("if not %ABC%=XYZ set ABC=XYZ"); Mike. -- Don't just hit "reply" - my E-mail address is bogus to avoid automatic browsers from sending junk mail. Please use collim'at'anubis'dot'network'dot'com Actually, even this doesn't stop all of them ...