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
Thanks,
Mega-Byte Computers
ASKER
That removes a printer connection. I need to delete a locally installed printer.
this would be the syntax for local printer.
objNetwork.RemovePrinterCo nnection "yourprinter" (Local Printer)
objNetwork.RemovePrinterCo
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\CurrentContro lSet\Contr ol\Print\P rinters"
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-2"
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-3"
Echo HKCU,"Printers\Connections "
Echo HKCU,"Software\Microsoft\W indows NT\CurrentVersion\PrinterP orts"
Echo HKLM,"SOFTWARE\Microsoft\W indows NT\CurrentVersion\Print\Pr oviders\La nMan Print Services\Servers"
Echo HKLM,"SYSTEM\ControlSet001 \Control\P rint\Monit ors\Standa rd TCP/IP Port\Ports"
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\M onitors\St andard TCP/IP Port\Ports"
Echo.
Echo [AddReg]
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\P rinters"," DefaultSpo olDirector y",,,
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\P rinters"," DefaultSpo olDirector y",,"%%Sys temRoot%%\ System32\s pool\PRINT ERS"
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-2",,,
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-2","Di rectory",, "2"
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-2","Ma jorVersion ",%%REG_DW ORD%%,2
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-2","Mi norVersion ",%%REG_DW ORD%%,0
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-3",,,
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-3","Di rectory",, "2"
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-3","Ma jorVersion ",%%REG_DW ORD%%,2
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\E nvironment s\Windows NT x86\Drivers\Version-3","Mi norVersion ",%%REG_DW ORD%%,0
Echo HKCU,"Printers\Connections "
Echo HKCU,"Software\Microsoft\W indows NT\CurrentVersion\PrinterP orts"
Echo HKLM,"SOFTWARE\Microsoft\W indows NT\CurrentVersion\Print\Pr oviders\La nMan Print Services\Servers"
Echo HKLM,"SYSTEM\ControlSet001 \Control\P rint\Monit ors\Standa rd TCP/IP Port\Ports"
Echo HKLM,"SYSTEM\CurrentContro lSet\Contr ol\Print\M onitors\St andard 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\rund ll32.exe setupapi,InstallHinfSectio n DefaultInstall 128 %TEMP%.\$%~n0.inf
Del %TEMP%.\$%~n0.inf
For %%F In (%SystemRoot%\system32\spo ol\drivers \w32x86) Do (
%SystemRoot%\system32\attr ib.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
@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\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKCU,"Printers\Connections
Echo HKCU,"Software\Microsoft\W
Echo HKLM,"SOFTWARE\Microsoft\W
Echo HKLM,"SYSTEM\ControlSet001
Echo HKLM,"SYSTEM\CurrentContro
Echo.
Echo [AddReg]
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKLM,"SYSTEM\CurrentContro
Echo HKCU,"Printers\Connections
Echo HKCU,"Software\Microsoft\W
Echo HKLM,"SOFTWARE\Microsoft\W
Echo HKLM,"SYSTEM\ControlSet001
Echo HKLM,"SYSTEM\CurrentContro
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.
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.
%SystemRoot%\system32\rund
Del %TEMP%.\$%~n0.inf
For %%F In (%SystemRoot%\system32\spo
%SystemRoot%\system32\attr
Del /Q /S %%F\*.*)
%SystemRoot%\system32\net.
http://www.msfn.org/board/lofiversion/index.php/t44848.html
ASKER
Only problem is I need it to just remove one specific printer and not all printers.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry to shoot it down again - it needs to work on Windows 2000.
Mega-Byte
Mega-Byte
ASKER
I got it...
rundll32 printui.dll,PrintUIEntry /n "Local Printer To Be Deleted" /dl
Thanks for all the help JoeZ430
Mega-Byte Computers
rundll32 printui.dll,PrintUIEntry /n "Local Printer To Be Deleted" /dl
Thanks for all the help JoeZ430
Mega-Byte Computers
ASKER
Giving points to JoeZ430 for pointing me in the right directions.
Mega-Byte Computers
Mega-Byte Computers
Glad to hear you got this working
:)
:)
http://computerperformance.co.uk/Logon/Logon_Remove_Printer.htm#Example_2_-_Full_RemoveNetworkDrive_Syntax_