Delete all printers on the desktop via scripting

  • Thread starter Thread starter Dwight
  • Start date Start date
D

Dwight

Does anyone know of a script which will delete all
printers on an W2K-Professional desktop?
 
I use Kixtart from www.scriptlogic.com to run all my scripts. The following is one that I created to delete all network printers
and then add a printer and set it as the default. It is based on the %username% that each users use to login with. Just make sure
that the users have rights to add printers on the machines or run the file with the super user utility (SU). Also this I put in for
those users to be in a Move group, that way you first can do testing and then put only those that need it done in the group and have
the script run for them as needed. Found it very useful when having to move office for people from floor to floor or building to
building, one less thing for me to worry about.



; Author - Tom Hagen
; E-Mail - (e-mail address removed)
;
; Needed Files:
; KIX32.EXE
; Printers.kix (This file)
; UserPrinter.ini
;
; This is used in conjunction with a UserPrinter.ini file in the format:
; [UserPrinter]
; Username=\\server\share,share name (as the users sees it not the UNC) no quotes
;
; To run this in login script use the following line:
; KIX32 Printers.kix
;
;
; The purpose of this is to make it easier to move computers and swap printers around without having to
; login as the user on each machine. Instead as soon as they are put into the NT Group called MOVE this
; will make all needed changes. Thereby lowering the cost of moving the computers.
;
; Place all three files in the root login script location, if put into a subfolder change the line:
; $PrinterInfo = Split(ReadProfileString(@LDrive + "\UserPrinter.ini","UserPrinter",@UserID),",")
; to be:
; $PrinterInfo = Split(ReadProfileString(@LDrive + "subfolder\UserPrinter.ini","UserPrinter",@UserID),",")



BREAK OFF
DEBUG OFF
DIM $PrinterInfo[1]



IF InGroup ("Move",0) ; Remove the semicolon and create nt group called Move and put the users in it for the update
? "Delete Network Printers if needed."
IF DelPrinterConnection ("") = 0
? "Disconnecting All Existing Network Printer Connections"
ENDIF



? "Get user information from UserPrinter.ini"
$PrinterInfo = Split(ReadProfileString(@LDrive + "\UserPrinter.ini","UserPrinter",@UserID),",")



?
? "Add Network Printers"
? "Add printer " + $PrinterInfo[0] + " for " @UserID
?
ADDPRINTERCONNECTION ($PrinterInfo[0])



?
? "Set Default Printer"
? "Set " + $PrinterInfo[1] + " as default printer"
?
SetDefaultPrinter ($PrinterInfo[1])



EndIf





The file that contains the needed information is called UserPrinter.ini it has the following in it:



[UserPrinter]

Username=\\server\share,share name (as the users sees it not the UNC) no quotes

Tom.Hagen=\\MBI-FPTS1\HPLasertJet8000,HP LaserJet 8000
 
Back
Top