Any Code or Function to uninstall KB's silently?

What is missing for you?
Error handling and logging?
You can add this yourself with this or ask for help here.