Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Remove Network Printers from Multiple Workstations

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,48627
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Remove Network Printers from Multiple Workstations
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Remove Network Printers from Multiple Workstations - 6/22/2007 4:50:31 AM   
  Wyvern


Posts: 11
Score: 0
Joined: 6/21/2007
Status: offline
Useful when performing migrations, etc...

'Comments Section
'-------------------------------------------------------------------
'VBS Multiple WS Network Printer Removal
'Created by Jim Martin 4:27 PM 8/24/2006
'Modified Microsoft Script to remove network printers
'Text file must be named machines.txt and located in script directory
'or the script will need to be edited
'-------------------------------------------------------------------- 
'End Comments
On Error Resume Next
Set WshNetwork = WScript.CreateObject("WScript.Network")
set ofs = createobject("scripting.filesystemobject")
set MachineList = ofs.opentextfile("machines.txt", 1, false)
while not MachineList.atEndOfStream
   strComputer = MachineList.ReadLine()
   wscript.echo vbCrLf & "Connecting to " & strComputer & "..."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
if (Err.Number <> 0) then
           wscript.echo "Failed to connect to " & strComputer & "."
On Error Resume Next
else
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
'Wscript.Echo "Name: " & objPrinter.Name
'Wscript.Echo "Location: " & objPrinter.Location
if InStr(objPrinter.Name, "\\") > 0 then
'wscript.echo "Will delete: " & objPrinter.Name
WshNetwork.RemovePrinterConnection objPrinter.Name
End If
Next
End If
Wend
MachineList.close()
Wscript.Echo "Finished removing network printers!"


 
 
Post #: 1
 
 RE: Remove Network Printers from Multiple Workstations - 8/7/2007 2:56:56 AM   
  clone13

 

Posts: 13
Score: 0
Joined: 7/20/2006
Status: offline
H i there,

I am quiet interested in your script to remove network printer connections for several workstations.  My only delema is that I want to only remove 2 specific network printers.  Each user here migh have several extra network printers in their "printers and faxes" list.  I have searched for this info without any success.  If you have an idea how, I would really appriciate it.

Thanks,

Clone13

(in reply to Wyvern)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Remove Network Printers from Multiple Workstations Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts