modify registry in user environment
env_list = []
new_env = 'D:\\Python27;D:\\Python27\\Scripts'
user_env = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, 'Environment')
try:
value, type1 = _winreg.QueryValueEx(user_env, 'PATH')
env_list = value.split(';')
for env in env_list:
if new_env == env:
print 'exist'
exit()
temp_env = value + ';' + new_env
print temp_env
except:
type1 = 1
temp_env = new_env
try:
_winreg.SetValueEx(user_env, 'PATH', 0, type1, temp_env)
except WindowsError as e:
print e
finally:
_winreg.CloseKey(user_env)