Why deleting an environment variable with reg delete HKCU\Environment /F /V TestVar
in Windows 7 Professional removes it from the registry, but the variable still exists?
Here are the details: I created the following 3 .cmd
files:
Check variable.cmd
echo TestVar = %TestVar%
pause
Set variable.cmd
setx TestVar 123
pause
Delete variable.cmd
reg delete HKCU\Environment /F /V TestVar
pause
Then I follow these steps (double clicking to make sure that I start a new session every time):
- Double click on
Check variable.cmd
and I see thatTestVar
does not exist - Double click on
Set variable.cmd
and it saysSUCCESS: Specified value was saved.
- Double click on
Check variable.cmd
and it shows the variable value. Good! - Double click on
Delete variable.cmd
and it saysThe operation completed successfully.
- Double click on
Check variable.cmd
and it still shows the variable value. Bad! - Click on the Start menu, type
environment
, click onEdit environment variables for your account
to open theEnvironment Variables
dialog box, clickOK
without changing anything - Double click on
Check variable.cmd
and the variable does not exist anymore
I can find the value in the registry after step 2, I cannot find it after step 4, but step 5 still finds it. And even if I don't change anything, step 6 really deletes the variable.
Aucun commentaire:
Enregistrer un commentaire