Currently, the EXE file of Kleopatra doesn’t actually close a number of processes that it starts and depends on for operation, even when Kleopatra itself is closed (not sure why the makers of Kleopatra did this, as it seems stupid, but there is a workaround). I found that I can fix this with a BAT file. This BAT file must be placed in the base folder for your installation of GPG4Win. It must contain these exact lines.
taskkill /F /IM dbus-daemon.exe
taskkill /F /IM scdaemon.exe
taskkill /F /IM gpg-agent.exe
taskkill is an EXE file that comes with Windows (not sure what the earliest version of Windows is that has it, XP, Vista, or 7). It works on my Windows 7 PC for sure, not sure about earlier versions.
You can then create your own shortcut to this BAT file, and place it in the start menu. Just make sure you don’t accidentally close the console window that the BAT file is running in before you close Kleopatra, or else it will not be able to close down the auxiliary processes after Kleopatra is closed.
This Kleopatra behaviour - (leaving these files running) was what I alluded to in another post, and it was suggested I write about it. However, I had not got around to that until now. These processes that Kleopatra starts but does not close were a problem as they would keep on running hogging my system. I had to kill them in Process Explorer. My question for you Animedude, is what name do you give the batch file?
I’d just call it something like launcher.bat, but the exact name is not important to its operation. Just pick something that makes sense so you will remember it.
I must confess to being uncertain about the operation of .bat files, but have read a bit yesterday.
The first line of your file “bin\ kleopatra” - what does that do?
Next question - am I to put the bat file in the following folder (on my machine) -
(that’s where the Kleopatra.exe file is.)
If that’s right, what makes the .bat file run AFTER Kleopatra is closed and not before?
Following on from my last post, I see by reading more carefully the last part of your first post, that the .bat file is to be run manually after closing Kleopatra. (I had thought that by putting it in the same folder as Kleopatra this someohow meant that it would be automatically run after closing Kleopatra!)
Bat file is meant to launch Kleopatra and then clean up after it is done running. The Kleopatra EXE file is located in the “bin” subdirectory of the main GPG4Win’s installation directory. The line “bin\kleopatra” executes the EXE file for the Kleopatra program (it runs the Kleopatra program). This is also why the BAT file in question MUST be placed in the directory that GPG4Win was installed in (the bin directory is a subdirectory of this installation directory). When an EXE file is executed from a BAT file, the computer waits for the executed program to terminate, before running the rest of the commands in the BAT file. So the other 3 lines in the BAT file (the ones that terminate the other processes that Kleopatra itself starts) will be run after Kleopatra is terminated by the user. Therefore your statement that the BAT file must be run after the Kleopatra program has been terminated is incorrect. It should actually be used to start Kleoatra as a kind of “launcher” for it, and then it will automatically clean up the extra running processes after Kleopatra has been closed (something that Kleopatra itself won’t do).
Many thanks Animedude for this bat file idea - now I understand how it works. I am sure that folks who are familiar with bat files would have caught on to this right away!!
I will use this - much appreciated!!
Note that those processes are services that should only consume very little resources.
They run because any applications using the crypto-backend my use them, for instance GpgOl, GgpEX or the command line.
Maybe few resources, but I have a sort of ideology regarding computer software. Any time a program is run by an end user, and that program starts other programs, as long as no other programs are also using these “dependency” programs, those additional programs should be closed by the program that ran them, when the program that ran them is terminated by the end user. This is particularly important for cryptography software. In situations demanding high anonymity, a person may take a copy of GPG4Win and put it on a USB drive and take it to a library to run it on one of the library’s computers. This makes it so any communication is not only encrypted by GPG4Win, but also cannot be tracked by IP address to your home. Unfortunately you can’t remove a USB drive from a PC until all programs running on it have been terminated (or else you risk corrupting data on the USB drive). If you close Kleopatra, and these additional programs are still running, and when you try to eject the USB drive Windows keeps saying that it’s in use, this could be a very bad situation. Imagine your adversary did track down the IP address to the library, and they are sending agents there, in person, to confront you. You will need to be able to get away as fast as possible, not fumble around trying to figure out what processes are running on that computer, and trying to close them down with Task Manager. The situation I described may sound like a scene out of a spy movie, but it is a real possibility in certain countries (like China and North Korea, where they REALLY crack down via law-enforcement on anybody who expresses any political view not approved of by the government).
To solve this very specific situation, I created this BAT file. I only wish the programmers of the Kleopatra GUI for GPG4Win had the foresight to think of putting this feature into the Kleopatra software itself, but since they didn’t, I am filling in where they left off, by providing this BAT file.
Animedude, What you say makes good sense to me. I usually use the GPA without starting Kleopatra when sending any email that needs to be encrypted, and I note that the gpg-agent file runs for that as well (I think only the latter not the others that your first batch file closes) and also does not close when GPA is closed. So I think I will make a batch file for that as well.