+ Post New Thread
Results 1 to 4 of 4
How do you do....it? Thread, Remove PDF Printers in Technical; Hi All I have a script to remove all the printers during logon, Code: On error Resume Next Dim cNetCommands, ...
  1. #1

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,074
    Thank Post
    160
    Thanked 937 Times in 731 Posts
    Blog Entries
    3
    Rep Power
    275

    Remove PDF Printers

    Hi All

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

    Code:
    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.

  2. #2

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,813
    Thank Post
    110
    Thanked 586 Times in 507 Posts
    Blog Entries
    1
    Rep Power
    225
    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.

    Removeing MS XPS Document Writer & Symantec Fax Starter Ed

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

  3. #3

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,074
    Thank Post
    160
    Thanked 937 Times in 731 Posts
    Blog Entries
    3
    Rep Power
    275
    ok i am bit of a noob when it comes to scripts so just laugh lol.

    is this right

    Code:
    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.

    James.

  4. #4

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,074
    Thank Post
    160
    Thanked 937 Times in 731 Posts
    Blog Entries
    3
    Rep Power
    275
    Ok i have done it..

    Code:
    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

SHARE:
+ Post New Thread

Similar Threads

  1. PDF Assocations
    By karldenton in forum Windows
    Replies: 1
    Last Post: 3rd September 2008, 11:01 PM
  2. [Joke] PDF
    By andy_d in forum Jokes/Interweb Things
    Replies: 5
    Last Post: 24th June 2008, 02:06 PM
  3. .PDF to whatever
    By mattx in forum Windows
    Replies: 6
    Last Post: 7th June 2008, 12:50 PM
  4. PDF Compresser
    By timbo343 in forum Windows
    Replies: 1
    Last Post: 2nd October 2006, 09:49 AM
  5. Create PDF
    By thom in forum Educational Software
    Replies: 6
    Last Post: 19th September 2006, 10:14 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •