Python Add Windows environment variables

Source: Internet
Author: User

How to add in 1.cmd
SET Path=%path%;c:\program Files (x86) \wireshark

Note: Add C:\Program Files (x86) \wireshark to the Windows environment variable as above code

However, the use of the Os.system () function in Python cannot execute the command, and no reason has been found yet.

2.python operation Windows Registry make changes
Import _winreg as Wgkey_test = WG. Openkey (WG. Hkey_local_machine,r "SYSTEM\CurrentControlSet\Control\Session manager\environment", 0,WG. key_all_access) PATH_STR = WG. QueryValueEx (key_test, ' path ') Path_str_new = path_str[0] + '; ' + ' C:\Program Files (x86) \wireshark ' WG. SetValueEx (key_test, ' path ', ' ', Path_str[1],path_str_new) WG. Flushkey (KEY_TEST) WG. Closekey (Key_test)

Note: The value of Path_str is (U ' c:\\python27\\; c:\\python27\\scripts; C:\\Program Files (x86) \\Intel\\iCLS client\\; C:\\Program Files\\intel\\icls client\\;%systemroot%\\system32;%systemroot%;%systemroot%\\system32\\wbem;% systemroot%\\system32\\windowspowershell\\v1.0\\;%systemroot%\\system32\\windowspowershell\\v1.0\\; C:\\Program Files\\intel\\intel (R) Management Engine components\\dal; C:\\Program Files\\intel\\intel (R) Management Engine components\\ipt; C:\\Program Files (x86) \\Intel\\Intel (R) Management Engine components\\dal; C:\\Program Files (x86) \\Intel\\Intel (R) Management Engine components\\ipt;; " C:\\Program Files (x86) \\Spirent communications\\spirent testcenter 4.68\\layer 4-7 Application "; C:\\Program Files\\tortoisesvn\\bin; C:\\python27;c:\\program Files (x86) \\Wireshark ', 2)

 

Python Add Windows environment variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.