Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Fri, 8 Aug 2008 09:43:00 -0700,    group: microsoft.public.inetsdk.programming.scripting.vbscript        back       


script to list all printers on print server Win2003 x64 in cluster   
Hello Scripting friends:

I'm trying to get a list of all my printers in my domain, I have a cluster 
of windows server 2003 x64 (file & print) and one node is for files and the 
other node is for printing. So I found and modify a script to do that in x32 
and non clusters enviroment.
Is there a chance to do this?

thanks for your help

the code:
***************************************
On Error Resume Next

Dim strComputer, strExcelPath, objExcel, objSheet, k, objGroup
Dim objWMIService, colItems, ErrState, Sheet

'Hoja = HOJA de calculo pagina, k = lineas en la hoja
Sheet = 1
k = 2

strComputer = InputBox ("Ingrese el nombre del print server a revisar, " & 
vbCrLf & _
   "Nombre del servidor","Print Servers en Polar")

if strComputer = "" then
  WScript.quit
end if

strExcelPath = InputBox ("Ingrese el nombre para guardar el archivo: ", 
"Print Server", "C:\Redes\Equipos\")

strExcelPath = strExcelPath & "Printers_" & strComputer & ".xls"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)

' Enlace a Excel.
On Error Resume Next
Set objExcel = CreateObject("Excel.Application")
If Err.Number <> 0 Then
  On Error GoTo 0
  Wscript.Echo "Excel no existe en este Equipo."
  Wscript.Quit
End If
On Error GoTo 0

' Crea el libro de trabajo.
objExcel.Workbooks.Add

'Cambie esto a conveniencia.
Select Case UCase(strComputer)
  Case "ALL"
    PrintServer("PSSW2MF02")
    Sheet = Sheet + 1
    PrintServer("IRGFS01")
    Sheet = Sheet + 1
    PrintServer("CCFLDR01")
  Case Else
    PrintServer(strComputer)
End Select

Function PrintServer(strComputer)

k=2
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)

' conecta a la hoja de trabajo.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(Sheet)
objSheet.Name = strComputer

' Encabezado en Excel con los atributos de las impresoras.
objSheet.Cells(1, 1).Value = "Nombre"
objSheet.Cells(1, 2).Value = "ShareName"
objSheet.Cells(1, 3).Value = "Comentario"
objSheet.Cells(1, 4).Value = "Error"
objSheet.Cells(1, 5).Value = "DriverName"
objSheet.Cells(1, 6).Value = "EnableBIDI"
objSheet.Cells(1, 7).Value = "Jobs"
objSheet.Cells(1, 8).Value = "Ubicacion"
objSheet.Cells(1, 9).Value = "NombrePuerto"
objSheet.Cells(1, 10).Value = "Published"
objSheet.Cells(1, 11).Value = "Queued"
objSheet.Cells(1, 12).Value = "Shared"
objSheet.Cells(1, 13).Value = "Status"

For Each objItem in colItems

'pone el error en palabras
Select Case objItem.DetectedErrorState
  Case 4
    ErrState = "Sin Papel"
  Case 5
    ErrState = "Bajo en Toner"
  Case 6
    ErrState = "Imprimiendo"
  Case 9
    ErrState = "Offline"
  Case Else
    ErrState = objItem.DetectedErrorState
End Select

'Llena las lineas con los siguientes datos de la impresora
objSheet.Cells(k, 1).Value = objItem.Name
objSheet.Cells(k, 2).Value = objItem.ShareName
objSheet.Cells(k, 3).Value = objItem.Comment
objSheet.Cells(k, 4).Value = ErrState
objSheet.Cells(k, 5).Value = objItem.DriverName
objSheet.Cells(k, 6).Value = objItem.EnableBIDI
objSheet.Cells(k, 7).Value = objItem.JobCountSinceLastReset
objSheet.Cells(k, 8).Value = objItem.Location
objSheet.Cells(k, 9).Value = objItem.PortName
objSheet.Cells(k, 10).Value = objItem.Published
objSheet.Cells(k, 11).Value = objItem.Queued
objSheet.Cells(k, 12).Value = objItem.Shared
objSheet.Cells(k, 13).Value = objItem.Status

k = k + 1
Next

' Formato de la hoja de calculo
objSheet.Range("A1:M1").Font.Bold = True
objSheet.Select
objSheet.Range("A2").Select
objExcel.ActiveWindow.FreezePanes = True
objExcel.Columns(3).ColumnWidth = 25
objExcel.Columns(5).ColumnWidth = 25
objExcel.Columns(6).ColumnWidth = 10
objExcel.Columns(8).ColumnWidth = 25
objExcel.Columns(1).ColumnWidth = 20
objExcel.Columns(9).ColumnWidth = 14
objExcel.Columns(2).ColumnWidth = 15
End Function

' Guarda la hoja de calculo y cierra el libro
objExcel.ActiveWorkbook.SaveAs strExcelPath
objExcel.ActiveWorkbook.Close

' Sale de Excel.
objExcel.Application.Quit

' Limpia
Set objUser = Nothing
Set objGroup = Nothing
Set objSheet = Nothing
Set objExcel = Nothing

WScript.Echo "Listado de impresoras ya fue generado"
date: Fri, 8 Aug 2008 09:43:00 -0700   author:   Gustavo

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us