I've got something in KiXtart that I use to remove all apps from a farm member so that I can remove the server from the farm when everyone has disconnected. I'll dig it out for you - it's not exactly what you are asking for, but it will get you started.