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