Page 1 of 1

Purge environment variable

Posted: Mon Jan 30, 2012 8:20 pm
by horst
SetEnvironmentVariable("Vdrive","")
should purge the variable. Instead the variable still exists (with empty assignment).
The equivalent API function works correctly.

For example (at the console) the command SET Vdrive
should display:
---- The environment variable is not defined
and not:
---- Vdrive=

Existing, but empty variables may have unpredictable consequences.

Re: Purge environment variable

Posted: Mon Jan 30, 2012 8:41 pm
by freak
Try RemoveEnvironmentVariable()

Re: Purge environment variable

Posted: Tue Jan 31, 2012 8:16 am
by horst
freak wrote:Try RemoveEnvironmentVariable()
Sorry, I did not expect this, because I was used to the DOS/Windows behaviour.
Now I always have to remember to use this construct for setting variables:

Code: Select all

If Vdrive
  SetEnvironmentVariable("Vdrive",Vdrive)
Else 
  RemoveEnvironmentVariable("Vdrive")
EndIf 
Edit: .. or use a macro..
Maybe a little hint in the SetEnvironmentVariable help would be helpful.