Login | |
|
 |
Re: List Printers - 5/13/2005 8:22:30 AM
|
|
 |
|
| |
royb5000
Posts: 54
Score: 0
Joined: 5/4/2005
From: USA
Status: offline
|
Thanks for the info, i used it and modified it a little and made it to where it will create an output file. All you have to do is create a txt file named computers.txt where ever the script is located that contains a list of computer names that you want to get the printer info for. Run the script after you create the text file, and it will create a file called printers.txt that contains all of the printers that are installed on each of your computers in your file Here is the code: Option Explicit On Error Resume Next Dim fso, src, dest, ts, output, temp, groups, user,WshShell,objWMIService,colInstalledPrinters,objPrinter Set fso = CreateObject("Scripting.FileSystemObject") src = "computers.txt" dest = "printers.txt" If Not fso.FileExists(src) Then WScript.Echo "File: """& src & " cannot be found." Else Set ts = fso.OpenTextFile(src,1) Set output = fso.CreateTextFile(dest,True) Do Until ts.AtEndOfStream temp = ts.ReadLine Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & temp & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") output.WriteLine "Printers currently installed on " & temp output.WriteLine " " For Each objPrinter in colInstalledPrinters output.WriteLine string(2,vbTab) & objPrinter.name Next output.WriteLine Loop End If Hope this helps some of you
|
|
| |
|
|
|
|
|