Link to home
Start Free TrialLog in
Avatar of JeffBeall
JeffBeallFlag for United States of America

asked on

get printer list script

I found the following script on the scripting guys website. I did NOT create this script - and I say that so emphatically because I know NOTHING about scripting.
Having said that, the script runs fine, except for remote computers on my network. For remote computers it only shows those "virtual" printers like Microsoft XPS document writer.
The way the network printers are installed they show up as
Printername on Printservername
and I don't know if that is an issue - also on the website it said something about 64bit computers - my computer is 64bit, but all the other computers on the network are 32bit.
So is there a way to adjust this script to show the network printers? Those are the only ones I'm conscerned about - I don't care about the "virtual" printers.

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
     
For Each objPrinter in colPrinters
    If objPrinter.Attributes And 64 Then
        strPrinterType = "Local"
    Else
        strPrinterType = "Network"
    End If
    Wscript.Echo objPrinter.Name & " -- " & strPrinterType
Next
Avatar of Kimputer
Kimputer

So you mean, you checked the computer not showing the printers in the script, but you checked through the computer > start > printers and faxes, and they're really there ?

How do you run the script anyway? You are physically at the computer to run the script?

Tested on 32bit XP Pro btw, and it's working as it should
Avatar of JeffBeall

ASKER

"but you checked through the computer > start > printers and faxes, and they're really there ?"

yes, the printers are there.

"How do you run the script anyway? You are physically at the computer to run the script?"

you don't have to be at the computer - from my laptop connected to the network - i change the variable

"strComputer = "

to whatever comptuer name I need and save the change, then simply run the script

"Tested on 32bit XP Pro btw, and it's working as it should"

I am running on win7 - would there need to be a change for that?
So, just to be thorough, can you really go sit behind a computer and run the script?
Using a script from remote could mean different credentials, meaning different results from what you'd expect. Network printers are stored in the user space.
hello?
sorry, I kept trying to post a comment and it wasn't working
so anyway
yes, I can run the script at the computer and it works, but that is not what i want to do.
so i was wondering if there is something wrong with the syntax, or if i could add a line to make it work with network printers.
ASKER CERTIFIED SOLUTION
Avatar of Kimputer
Kimputer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you