Don't worry you have done me a massive favour!!
Printable View
Anytime, As per @sted mentioned, just curious if there is a more official and better method of doing this. I know you can use the rundll32 printui.dll command to delete / remove printers, not sure in regards to GPO / GPP etc as far as it removing printers ??
edit - @Steve21 is a lot better than myself at coding, think I've managed to leave illegal operators etc in previous code so still got a learning curve.
Still never managed to get the HTA working as I wanted - I still liked the way you formatted the html and combined that with WMI querries etc lol.
There isn't any other keys that need deleting from HKCU or the likes as a comment above states that something else points to the HKU keys ?
Not from what I can see and have read elsewhere - essentially after an old server was decommissioned the printers where lingering on the client machines (although they should have previously been removed). But windows tends to get funny when you try to delete printers on a machine which don't exist any more.
Just as an update ( may or may not find this helpful / handy etc ) but found this link :
Remove Printer Definition from the Registry
Quote:
There is a problem with NT printer definitions that may cause you problems. You follow standard advice to uninstall and reinstall the printer driver. Sometimes this doesn't fix the problem and you have no choice but to remove a printer. When you use the Remove or Delete Printer options in Print Manager, the printer connection disappears immediately. However, the spooler simply marks the printer for deletion. NT doesn't actually delete the printer until you reboot the system. Sometimes NT will delete the definition if you stop and restart the spooler. Sometimes it doesn't. If this doesn't work, and you will find out when you try to redefine the printer. No issue for workstations. You can reboot. Unfortunately there are servers which can not be rebooted (or at least not for something like a printer definition). For servers which can not be rebooted, you can remove the printer definition from the registry by hand prior to the reinstall. If it is a local printer (My Computer), go to the following registry keys and delete the respective entries:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Print\Environments\ Windows NT x86\ Drivers\Version-2\
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Print\Printers\
If it is a network printer (network printer server or \\), go to the following registry keys and delete the respective and entries:
HKEY_CURRENT_USER\Printers\Connections\
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Print\Providers\ LanMan Print Services\Servers\\Printers\
After the registry edit, you need to stop and restart the spooler service. At this point, you'll be able to reinstall the printer driver correctly.