Tag Archives: batch

Remove Network Printers from Users Before they Log On

Dos Batch FileI had a little trouble with an HP Printer driver that was causing the Vista PCs to hang at logon.

Without going into the specifics of the problem (which comes down to poor HP drivers), I needed a way to ensure that the driver wouldn’t be active the next time that a user logged onto a computer.

A bit of quick thinking, and I quickly knocked up this command, that will enumerate all users in a folder and make the appropriate change while they are offline. Hurrah!

<code>for /D %D in (\\domain.local\users\*.*) DO (
  reg load HKU\UserLoad %D\profile.V2\ntuser.dat
  reg delete "HKU\UserLoad\Printers\Connections\,,domainsrv1,Suite Mono Printer" /f
  reg delete "HKU\UserLoad\Printers\Connections\,,domainsrv1,Suite Colour Printer" /f
  reg unload HKU\UserLoad
)</code>

This assumes that all of your users live in \\domain.local\users and that you are cleaning up vista profiles. Needless to say, you’d probably want to adjust this if you need to do something similar.