Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Kill the process for a remote computer by Python in QT

Kill the process for a remote computer by Python in QT

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    monamour
    wrote on 21 Apr 2019, 05:47 last edited by monamour
    #1

    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,

    S 1 Reply Last reply 24 Apr 2019, 14:15
    0
    • K Offline
      K Offline
      Kent-Dorfman
      wrote on 23 Apr 2019, 03:11 last edited by
      #2

      I've done this, but doing it well is a lot more complicated than you might think. You need to consider:

      1. communications channel to client machine
      2. encryption/security
      3. authoritative inquiry about the remote task you're killing
      4. 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.

      1 Reply Last reply
      0
      • M monamour
        21 Apr 2019, 05:47

        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,

        S Offline
        S Offline
        strahlex
        wrote on 24 Apr 2019, 14:15 last edited by
        #3

        @monamour Read the subprocess.call documentation or use QProcess (and read the documentation).

        Feel free to check out my website machinekoder.com
        and my pet projects Intellicute and QtQuickVcp

        1 Reply Last reply
        0

        1/3

        21 Apr 2019, 05:47

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved