Results 1 to 8 of 8

Thread: How to kill process

  1. #1
    Join Date
    Jul 2007
    Posts
    36

    Default How to kill process

    I'm trying to set up an action in girder to kill a program (e.g. Skype) that is minimized to the system tray.

    I've created a 'scripting' action in Girder and entered the following command, but nothing happens.

    TerminateProcess (FindProcess ("skypePM.exe"))

    I'm not familiar with lua (if this is relevant) and am struggling to troubslihsoot where I am goign wrong.

    Can anyone point me in the right direction ?

    many thanks

  2. #2
    Join Date
    Nov 2005
    Location
    Redditch, UK
    Posts
    957

    Default

    I found that when watchdog restarted Girder I ended up with multiple versions of programs I started with Girder so wrote this little function to kill off all the processes before I re-started it.

    Code:
    function KillAll(handle)
    local found = true
     while found == true do
      xlHandle,xlErr = win.FindWindow(nil,handle)
      print("Handle: ",xlHandle)
      if xlHandle ~= nil then
       win.KillWindow(xlHandle, 1)
      else
       found = false
      end
     print(">> All Killed: ", handle)
     end
    end
    The handle is the title of the window btw.
    - John H
    * PROMIXIAN TO THE CORE! * (NetRemote2WholeHomePro + Girder5WholeHomePro + USB-UIRT + Touchscreens + WirelessControlSystems + ANNA) == AutomationHeaven
    - "IthinkI'mgoingtobantheuseofthespacebarinfuture..."

  3. #3
    Join Date
    May 2004
    Posts
    2,577

    Thumbs down

    Can someone please explain to me why my script will not work? It actually makes my cursor disappear for some reason and then I have to reboot.
    I'm going on a trip soon and my insteon SDM3.exe locks up everyday. That kind of makes having my lights on timers pointless if I have to be there to reset the SDM everyday. I figured I could have Girder restart it automatically twice a day, but I cannot kill the process to start it up again.

    Here is my script:
    Code:
    local handle = handle or 0
    handle, err = win.FindWindow(nil,SDM3)
    win.KillWindow(handle, 1000)
    Thanks.
    Beware of the robot.

  4. #4
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    Unless you have a variable called SDM3 you need to put that in quotes.

    You should definitely check that handle is not nil before you call KillWindow.
    --Rob

  5. #5
    Join Date
    May 2004
    Posts
    2,577

    Default

    Thanks for your help.
    I've modified the script like this:
    Code:
    local handle = handle or 0
    handle, err = win.FindWindow(nil,"SDM3.exe")
    if handle ~= nil then win.KillWindow(handle, 1000)
    else print ("SDM3 not found")
    end
    but it always prints "SDM3 not found", even though I can see it in the system tray and in my task manager. Can you see anything else that I'm doing wrong? I've tried running the script with and without the ".exe" extension in the string.
    Beware of the robot.

  6. #6
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    FindWindow looks for a window with the title specified in that parameter, not the name of the process. What does the the window you're trying to find look like?
    --Rob

  7. #7
    Join Date
    May 2004
    Posts
    2,577

    Default

    ah ha. Well, the SDM3 sits in the system tray. Is there a way to kill it if it is not an open window?
    Beware of the robot.

  8. #8
    Join Date
    May 2004
    Posts
    2,577

    Default

    It seems to work while it's in the tray once I followed your instructions and typed out the full window name as "Smarthome Device Manager 1.01.122.278". Girder then restarts it automatically. I haven't tested it yet, but it looks like the problem is solved. Thanks again.
    Beware of the robot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •