Page 1 of 1

SETX - delete environment variable

Posted: 2023-Jan-26, 12:03 pm
by Simon_Weel
I was doing some testing which incorporated a couple of environment variables. I used SETX to create those variables in the user's context to be picked up by other applications. When done testing, I wanted to get rid of them using SETX. Now there doesn't seem to be a way do delete environment variables with SETX - the help text doesn't list a switch for that. But I found out entering double quotes does the thing. So:

Code: Select all

SETX MyEnvironmentVariable ""
effectively deletes the environment variable.

Re: SETX - delete environment variable

Posted: 2023-Jan-26, 2:06 pm
by JoeC4281
According to https://ss64.com/nt/setx.html
Setting value of "" (empty quotes) will appear to delete the variable - it's not shown by SET but the variable name will remain in the registry.
Joe

Re: SETX - delete environment variable

Posted: 2023-Jan-31, 10:31 am
by Simon_Weel
Oops, missed that! :oops: