MSFN Forum: Deleting a Printer and Printer port - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Deleting a Printer and Printer port Rate Topic: -----

#1 User is offline   frontier6444 

  • Group: Members
  • Posts: 2
  • Joined: 08-September 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 08 September 2010 - 09:23 AM

What I am trying to accomplish is to delete a printer on a remote machine without having to connect to it. Here is what I have so far:

strComputer = inputbox("Please enter the computer name or IP address.","Computer Name")

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer where DeviceID = 'Printer1'")

For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next


Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPorts = objWMIService.ExecQuery _
("Select * from Win32_TCPIPPrinterPort Where Name = 'Printer1'")
For Each objPort in colInstalledPorts
Objport.Delete_
Next


"Printer1" is of course the name of the printer I am removing and this works perfectly but what I would like to do if possible is have it prompt me in a inputbox the name of the printer and whatever is typed in the box goes to where the printer name needs to be in the script. Any assistance would be greatly appreciated. Thank you!


#2 User is offline   mritter 

  • WPI Co-Developer
  • Group: Developers
  • Posts: 1,088
  • Joined: 13-November 05

Posted 08 September 2010 - 06:25 PM

That's a pretty specialized use. Most people would want to ADD a printer.

I printed out your request.......I will see.........

#3 User is offline   mritter 

  • WPI Co-Developer
  • Group: Developers
  • Posts: 1,088
  • Joined: 13-November 05

Posted 09 September 2010 - 01:43 PM

Also, when are you planning on running this script? Before or during the install process? If before, then would be easy to make one like the other settings wizards. You would have to know the names ahead of time.

If during the install process, then no, no prompt box.

#4 User is offline   frontier6444 

  • Group: Members
  • Posts: 2
  • Joined: 08-September 10
  • OS:XP Pro x86
  • Country: Country Flag

Posted 13 September 2010 - 06:22 AM

This is to remove printers already installed. Sometimes we have printers that get hosed up and need to be reinstalled. So technically after.

#5 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,108
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 13 September 2010 - 07:21 AM

Maybe this helps:
http://www.robvander...rintcontrol.php
(or maybe not :unsure:)

jaclaz

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy