Printers need deleting

  • Thread starter Thread starter Peter Loerns
  • Start date Start date
P

Peter Loerns

Hi, we are a using the below script which loads network printers in
one of our classrooms at our school. I want to add a line that deletes
all installed printers first before it installs the specified ones
below. This script was written for us by someone else and not being a
VB person, I am lost. Any help gratefully appreciated

Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\wpadmin\Colour_Laser"

Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\wpadmin\ICT1_Laser"

Set net = CreateObject("WScript.Network")
net.SetDefaultPrinter "\\wpadmin\ICT1_Laser"
 
In Microsofts Resourse Kit there's a tool called prnadmin.dll. There's also
a file prnadmin.doc with documentation.

Take a look at the clean.vbs example. You plobably don't even need to modify
it since it works with command line parameters. What it does is to remove
all printing components from a pc. Including ports and drivers.

If you wish I can send you my modified version that don't take command line
parameters... I could also send you a script just removing the printer
queues if that's what you want.

Good luck! :)

/Sofia
 
Is there not a line i can add at the beginning of the VB script that
deletes all installed printers first before deleting
 
Hi,
I am using a script to set a network printer through code:
A txtPrinter name is sent to the code file executing print. This txtPrinterNm comes through the profile of the user who is trying to print (a default printer is set in his user ID).
The problem is that the print is going to any one of the other printers that had been set by the user previously in his profile and the print does not come on the currently set printer. Is there any way to code something to refresh the cache/printer name(s) each time before a job is printed.
This problem becomes severe if more than one user are trying to print concurrently with different printers set in there profiles. The job is spooled and printed on any of the printers for all the users and not on their respectively set printers.

I also tried the following script but it did not work:
PrinterOptions.ReportPrinterOptions.PrinterName = txtPrinterNm
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection(txtPrinterNm)
net.SetDefaultPrinter(txtPrinterNm)
 
Back
Top