Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Kill the process for a remote computer by Python in QT
monamour last edited by monamour
I have designed an application by PYQT5 and python 3.6 to kill the process in localhost by write the process name in 'lineEdit' as below in the code then hit 'kill' button to kill it.
What I want is to kill the process in remote computer by fetching the data first then check the name of the process that I want to kill then BOOM!.
The code below to kill the process in localhost only NOT in the remote 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
The code below to kill the process in remote PC by using batch file, however, is not showing in textBrowser in QT just showing in Pycharm editor,
def kill_process(self): x=subprocess.call([r'C:\Pycharm\projects\proj\rp.bat']) self.textBrowser_3.setText(x)
The batch file (rp.bat),
@echo off set /p comp=Please put the computer name: wmic /node:%comp% process where name="thunderbird.exe" call terminate >>nul pause
Thanks in advance,
Kent-Dorfman last edited by
I've done this, but doing it well is a lot more complicated than you might think. You need to consider:
- communications channel to client machine
- authoritative inquiry about the remote task you're killing
- adequate privilege to carry out the terminate operation
These issues are more complicated if you are in a heterogenous OS environment: linux, windows, mac, embedded, etc.
strahlex last edited by
@monamour Read the subprocess.call documentation or use QProcess (and read the documentation).