GPG agent sometimes stuck when you put your PC to sleep mode or when you unplug and plug your YubiKey back. This Solution will restart the GPG agent with every connection of YubiKey.
- Create a "yubi-reset.bat" file on your disk and put there this content:
gpg-connect-agent killagent /bye
gpg-connect-agent /bye
- Open Event Viewer
- Go to Windows Logs → System
- Connect YubiKey and refresh the list, you should see info event with source "WudfUsbccidDrv"
- Right click this event and select "Attach Task To This Event"
- Go thru the wizard and on "Start a Program" step enter path to your "yubi-reset.bat" file
- That's it. Now whenever you connect your YubiKey, the GPG agent will be restarted.