def del_env(name):
    key = OpenKey(HKEY_CURRENT_USER, 'Environment', 0, KEY_ALL_ACCESS)
DeleteValue(key, name)
CloseKey(key)
SendMessage(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0,
    'Environment')
Deleting a Windows Registry Value with Python