Jump to content
EduGeek EdSec 2026 is on Tuesday in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

Hi All

 

I have a script to remove all the printers during logon,

 

On error Resume Next

Dim cNetCommands, vPrinterName, vPrinterPath

Set cNetCommands = WScript.CreateObject("WScript.Network")

Set vPrinterPath = cNetCommands.EnumPrinterConnections

For Each vPrinterName in vPrinterPath
cNetCommands.RemovePrinterConnection(vPrinterName)
Next

 

That works no problem, but it dont delete the PDF printers that are added by default when a student/staff logon, the ICT Teachers wish for these to be deleted. what code do i have to add so that it does this?

 

Any help would be appriciated.

 

Thanks

 

James.

Posted

The problem you are having is that you are only looping through the network printer connections. These PDF printers you are refering too are most probably setup like a local printer and just use a specialised printer port.

 

Anyhow, we have discussed this previously. See this thread.

 

http://www.edugeek.net/forums/how-do-you-do/8558-removeing-ms-xps-document-writer-symantec-fax-starter-ed.html

 

You should be able to adapt the code there to do what you need.

Posted

ok i am bit of a noob when it comes to scripts so just laugh lol.

 

is this right

 

On error Resume Next

Dim cNetCommands, vPrinterName, vPrinterPath

Set cNetCommands = WScript.CreateObject("WScript.Network")

Set vPrinterPath = cNetCommands.EnumPrinterConnections

For Each vPrinterName in vPrinterPath
cNetCommands.RemovePrinterConnection(vPrinterName)
Next

For Each objPrinter in colInstalledPrinters
IF objPrinter.Name = "Microsoft Office Document Image Writer" THEN 
	objPrinter.Delete_
ELSEIF objPrinter.Name = "Microsoft XPS Document Writer" THEN
	objPrinter.Delete_
ELSEIF objPrinter.Name = "CutePDF Writer" THEN
	objprinter.delete_
ELSEIF objprinter.Name = "PrimoPDF" THEN
	objprinter.delete_
END IF
Next

 

i have tried it and it dont delete the printers, but as i say i dont know whats wrong and right when it comes to this. i have run the script it dont error but it dont delete the printers either.

 

Thanks.. and sorry for been so dumb lol. :o

 

James.

Posted

Ok i have done it.. :D

 

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery ("SELECT * FROM Win32_Printer")

For Each objPrinter in colInstalledPrinters
IF objPrinter.Name = "Microsoft Office Document Image Writer" THEN 
	objPrinter.Delete_
ELSEIF objPrinter.Name = "Microsoft XPS Document Writer" THEN
	objPrinter.Delete_
ELSEIF objPrinter.Name = "CutePDF Writer" THEN
	objprinter.delete_
ELSEIF objprinter.Name = "PrimoPDF" THEN
	objprinter.delete_
END IF
Next

 

Works

 

James.

 

Thanks Geoff

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...