SETX - delete environment variable

Microsoft Windows
Post Reply
Simon_Weel
Posts: 34
Joined: 2021-Dec-13, 3:53 pm

SETX - delete environment variable

Post 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.
JoeC4281
Posts: 8
Joined: 2021-Jul-26, 12:51 pm

Re: SETX - delete environment variable

Post 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
Simon_Weel
Posts: 34
Joined: 2021-Dec-13, 3:53 pm

Re: SETX - delete environment variable

Post by Simon_Weel »

Oops, missed that! :oops:
Post Reply