Solved

get printer list script

Posted on 2013-11-12
7
556 Views
Last Modified: 2013-11-18
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
0
Comment
Question by:JeffBeall
  • 4
  • 3
7 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 39641888
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
0
 
LVL 1

Author Comment

by:JeffBeall
ID: 39642328
"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?
0
 
LVL 35

Expert Comment

by:Kimputer
ID: 39644216
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.
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 1

Author Comment

by:JeffBeall
ID: 39651606
hello?
0
 
LVL 1

Author Comment

by:JeffBeall
ID: 39651614
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.
0
 
LVL 35

Accepted Solution

by:
Kimputer earned 500 total points
ID: 39653392
Have it run under the user (when he logs in, so do it through a group policy that runs after log in, because if you put it at computer start, it's still the system account), and report the output back in another way (email or file on the network).
0
 
LVL 1

Author Closing Comment

by:JeffBeall
ID: 39656872
thank you
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now