Link to home
Start Free TrialLog in
Avatar of Megabyte_Computers
Megabyte_Computers

asked on

Remotely remove a local printer with script/utility

I have a network with around 300 Windows 2000 workstations and they all have the "Microsoft Office Document Image Writer" printer and I would like to remove it off all the PC's using some sort of utility or script to run on all the PC's using a group policy.  We have a VB Script that remove network mapped printer but not the local printer.  Does anyone know of a way to do this?



Thanks,
Mega-Byte Computers
Avatar of Joe
Joe
Flag of United States of America image

Avatar of Megabyte_Computers
Megabyte_Computers

ASKER

That removes a printer connection.  I need to delete a locally installed printer.
this would be the syntax for local printer.

objNetwork.RemovePrinterConnection "yourprinter" (Local Printer)
It seems like this script would do the trick also

@Echo Off
   If Not %1'==/?' Goto Begin
   Echo Removes Windows NT's printers (Registry-settings and printer driver's files).
   Echo.
   Echo %~n0
  (Goto :EOF)
  :Begin
  (Echo [Version]
   Echo Signature = "$Windows NT$"
   Echo.
   Echo [DefaultInstall]
   Echo DelReg = DelReg
   Echo AddReg = AddReg
   Echo.
   Echo [DelReg]
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers"
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-2"
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3"
   Echo HKCU,"Printers\Connections"
   Echo HKCU,"Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts"
   Echo HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\LanMan Print Services\Servers"
   Echo HKLM,"SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports"
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports"
   Echo.
   Echo [AddReg]
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers","DefaultSpoolDirectory",,,
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers","DefaultSpoolDirectory",,"%%SystemRoot%%\System32\spool\PRINTERS"
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-2",,,
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-2","Directory",,"2"
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-2","MajorVersion",%%REG_DWORD%%,2
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-2","MinorVersion",%%REG_DWORD%%,0
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3",,,
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3","Directory",,"2"
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3","MajorVersion",%%REG_DWORD%%,2
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3","MinorVersion",%%REG_DWORD%%,0
   Echo HKCU,"Printers\Connections"
   Echo HKCU,"Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts"
   Echo HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\LanMan Print Services\Servers"
   Echo HKLM,"SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports"
   Echo HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports"
  Echo.
   Echo [Strings]
   Echo REG_SZ         = 0x00000000
   Echo REG_MULTI_SZ   = 0x00010000
   Echo REG_EXPAND_SZ  = 0x00020000
   Echo REG_BINARY     = 0x00000001
   Echo REG_DWORD      = 0x00010001)>%TEMP%.\$%~n0.inf
   If Not Exist %TEMP%.\$%~n0.inf (
     Echo Can not write to: %TEMP%.\$%~n0.inf
     Goto :EOF)
   Echo Remove all printers on %COMPUTERNAME%
   %SystemRoot%\system32\net.exe STOP SPOOLER
   %SystemRoot%\system32\rundll32.exe setupapi,InstallHinfSection DefaultInstall 128 %TEMP%.\$%~n0.inf
   Del %TEMP%.\$%~n0.inf
   For %%F In (%SystemRoot%\system32\spool\drivers\w32x86) Do (
     %SystemRoot%\system32\attrib.exe -r -s -h %%F\*.* /S
     Del /Q /S %%F\*.*)
   %SystemRoot%\system32\net.exe START SPOOLER

http://www.msfn.org/board/lofiversion/index.php/t44848.html
Only problem is I need it to just remove one specific printer and not all printers.
ASKER CERTIFIED SOLUTION
Avatar of Joe
Joe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry to shoot it down again - it needs to work on Windows 2000.

Mega-Byte
I got it...

rundll32 printui.dll,PrintUIEntry /n "Local Printer To Be Deleted" /dl

Thanks for all the help JoeZ430


Mega-Byte Computers
Giving points to JoeZ430 for pointing me in the right directions.


Mega-Byte Computers
Glad to hear you got this working

:)