0

The problem was described at https://developer.pidgin.im/ticket/9698.

In Linux, I can ask pidgin to close via pkill pidgin or kill [pid]. The program will then take care of it and shut itself down. Windows doesn't work this way. A WM_CLOSE signal will only close the window, not the process (just like when you hit the x yourself).

How do I close pidgin via command?

Motivation: It seems that many XMPP servers need the clients to actively say "goodbye" in order to realize they're offline. In other words, there are no keep-alive packets needed or there are no timeouts (and if, quite delayed). Usually, this is no big problem, because we start and exit our clients accordingly (counting shutdown as exiting). However, if one goes into suspend/hibernate mode, it's just as if the network connection were gone suddenly - no chance for pidgin to say "hey there, going offline". So, I need a script to automatically close pidgin gracefully (to be executed directly before suspending).

2 Answers 2

0

The utility you want is taskkill.exe, which is a command-line program built into the Windows OS (roughly analogous to kill on Unix-like systems) and found in the system directory (C:\Windows\System32\taskkill.exe). By default, it asks (but does not force) programs to exit, and does not use window messages.

Run taskkill /? from a command line shell (cmd or powershell) for usage information, but the basic command you want is taskkill /im pidgin.exe (note that the extension is necessary on the image name of the program to kill). Do NOT pass the /f flag here, as this will forcibly terminate the program (analogous to kill -9) without giving it time to perform any cleanup (though that is useful for programs you want to kill immediately, or that are hung and don't respond to normal close requests).

Getting this to run automatically at logoff may be tricky; consider using Task Scheduler.

0

Here is an AutoHotkey script which emulates the following user steps:

  • Open main window if not open already
  • Send Ctrl-Q to it so pidgin quits

.

pidginMainWindowTitle := "Buddy List"

process, exist, pidgin.exe
if(ErrorLevel!=0) {
    ; Pidgin process is running -> close it
    if(!winExist(pidginMainWindowTitle)) {
        ; ..but main window is not.
        ; determine full pidgin path
        winGet, pidginPath, ProcessPath, ahk_exe pidgin.exe
        if(pidginPath=="") {
            msgbox, Process path empty?
            exitapp
        }
        ; run pidgin again: will open main window
        run %pidginProcessPath%
        ; wait for the window max. 2 seconds
        winWait, %pidginMainWindowTitle%,, 2
        if(ErrorLevel==1) {
            msgbox, Couldn't start main window
            exitapp
        }
        ; send exit key combo to pidgin main window
        controlSend,, ^q, %pidginMainWindowTitle%
        ; wait for the process to close max. 2 seconds
        process, WaitClose, pidgin.exe, 2
        if(ErrorLevel) {
            msgbox, Couldn't exit pidgin gracefully
            exitapp
        }
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .