Kill the process for a remote computer by Python in QT
-
wrote on 21 Apr 2019, 05:47 last edited by monamour
Dear All,
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!.
Any ideas?
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,
-
wrote on 23 Apr 2019, 03:11 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
- encryption/security
- 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.
-
Dear All,
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!.
Any ideas?
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,
1/3