使用Python远程终止电脑进程

2024-03-28 21:40:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我用PYQT5和python3.6设计了一个应用程序,通过在“lineEdit”中写入进程名,然后按“kill”按钮来终止localhost中的进程。你知道吗

我想要的是通过先获取数据然后检查我想要终止的进程的名称来终止远程计算机中的进程!。你知道吗

有什么想法吗?你知道吗

提前谢谢。你知道吗

只在localhost中而不是在远程pc中终止进程的代码

def Process(self):
        x=self.lineEdit.text()
        self.textBrowser.clear()
        for proc in psutil.process_iter():
            if proc.name()==x:
                proc.kill()
                self.lineEdit.clear()
                QMessageBox.information(self, "Success", x + " has been terminated")
                return
        for proc in psutil.process_iter():
            if proc.name()!=x:
                print(proc)
                QMessageBox.information(self, "Error","The process " +x + " is not found")
                return

System for killing the process


Tags: nameinselflocalhostforif远程进程