I ran into a problem with netowrk printers recereating / reinstalling themselves several times, so I found an old script command and placed it into the login script to remove specific printer entries:
rundll32 printui.dll,PrintUIEntry /dn /n \\<UNC>\<PRINTERNAME>
The approach was intended to remove specific existinng netowrk printers and re-install them fresh every time the user logged on. This seemed to work fine for quite some time.
Eventually, I upgraded the script to use the nifty CON2PRT function to delete all network printers and pause for 3 seconds to let the system settle:
\\<unc to server>\netlogon\CON2PRT /F ping -n 3 127.0.0.1 >NUL
Recently, however, the client reported a problem where network printer settings and driver options were getting seriously messed up. In addition to this, severl copies (in some cases as many as 12) copies of a single network printer were being installed on the client. Whether this was caused by a bad MS patch or something else I don’t know… In any event, it needed to be fixed.
I needed to find a script or command that would definitively clean up any and all TCP / network based printers and re-install from scratch. I discovered the Windows Management Instrumentation Command-line (WMIC). WMIC “…uses the power of Windows Management Instrumentation (WMI) to enable systems management from the command line…”.
Using this new WMIC tool, I modified the login script to call a batch file that ran a one line command to clean up all network printers. In my case, all network printers use a standard naming convention of IP_<IP address>. The batch file I called from the login script was this:
wmic printer where “PortName LIKE ‘IP_%%’” delete
Note – you normally only have to put one “%”, but because the command line reads the first “%” as a special character, you have to put two to make the command work.
After running the new login script on the client machines, all existing TCP printers were zapped and a fresh copy of the network printer was installed on each machine.
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.