Sponsored Links

Login Form






Lost Password?

Syndicate

Home
Remove Printers Using Print Server Name PDF Print E-mail
User Rating: / 3
PoorBest 
Written by Cheyenne Harden   
Two things keep me employed 1. Stupid People and 2. Printers!
Just after Christmas we had a server go down (This was our print server).
It cause all kinds of trouble reinstalling and such... but the biggest pain
were the printers (Their were so many of them). With all of the Terminal servers
using printer scripts and having users who cannot change their settings cause printers
to not be removed when the printserver is gone. To fix this issue I created this script
it will remove all printers from a specified "print server" (e.g., \\PSVR\colorlaser01).
This script can be run as a login script or added to an existing printer script.

----------COPY EVERYTHING BELOW THIS LINE----------

'This script will remove printer for the specified print server
'Created by Cheyenne Harden 1.10.07

On Error Resume Next

Dim arrPrinterName()
Dim strComputer, i, PrintServer
Dim objWMIService, objNetwork, colInstalledPrinters, objPrinter

strComputer = "."
i = 0
PrintServer = "PSVR" 'Your Print server name goes here!

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

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

 For Each objPrinter in colInstalledPrinters
 'This line is used for trouble shooting
    'Wscript.Echo "Name: " & objPrinter.Name
 
 ReDim Preserve arrPrinterName(i)
 arrPrinterName(i) = objPrinter.Name
  If InStr(arrPrinterName(i), PrintServer) Then
   Set objNetwork = WScript.CreateObject("WScript.Network")
   objNetwork.RemovePrinterConnection arrPrinterName(i)
   i=i+1
  
  Else
   'This line is used for trouble shooting.
   'WScript.Echo  "Name: " & objPrinter.Name
   
  End If


Next


----------COPY EVERYTHING ABOVE THIS LINE----------

 

PLEASE MAKE SURE NO WORD WRAPPING IS HAPPENING IN YOUR SCRIPT!!!

To make this script work you will need the items below!


1. Run this as a LogOn script.
2. Add the Print Server name here (PrintServer = "PSVR" 'Your Print server name goes here!) .
3. You will need the ability to remove printers.


This information is provided "AS IS" with no warranties expressed or implied.

Comments
Add NewSearch
KDelsite - OS Specific?   | Registered | 11-04-2007 11:23:43
This seems to work with XP, but not under W2K.
LazyNetworkAdmin - Need WSH 5.6   | Super Administrator | 11-04-2007 14:54:43
you need Windows scripting host version 5.6 installed on any machine this gets ran on.
McG   | 170.185.132.xxx | 18-12-2007 17:34:17
I tried the script, but I found out that the results were case-sensitive.

Try replacing this on line 26 and it will make the results all lowercase. Then just enter the lowercase string for your printername and it should work.

If InStr(LCase(arrPrint
erName(i)), PrintServer) Then
Jeff   | 24.187.98.xxx | 22-04-2008 21:08:55
That was a clever idea..never though of a script to do this before. Usually if my printers went offline from the office we had to manually add them back on through Network settings.
---------------------
ventrilo hosting
wholesale jewelry - wholesale jewelry     | 222.131.26.xxx | 10-11-2008 21:49:02
wholesale jewelry
handmade jewelry
handcrafted jewelry
jewelry wholesale
wholesale handmade jewelry
pearl jewelry
wholesale pearl jewelry
wholesale turquoise jewelry
wholesale coral jewelry
wholesale shell jewelry
wholesale gemstone jewelry
wholesale crystal jewelry
fashion jewelry
wholesale jewellry
[url=h...
jewelry wholesale - jewelry wholesale     | 222.131.26.xxx | 10-11-2008 21:52:48
wholesale jewelry
jewelry store
fashion jewelry
crystal jewelry
jewelry wholesale
pearl jewelry
wholesale crystal
wholesale pearl
wholesale turquoise
wholesale semi-precious jewelry
wholesale coral
wholesale shell
wholesale swarovski crystal
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
 
Security Image
Please input the anti-spam code that you can read in the image.

Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved.

 
Tag it:
Delicious
Furl it!
Spurl
digg
YahooMyWeb
< Prev   Next >
 

Google Search

Google