Solved

How to script enumerating installed printer drivers?

Posted on 2010-08-24
10
1,094 Views
Last Modified: 2013-12-01
I have a vbscript that enumerates all the printers on a given server, and includes most of the information I need.  The last piece I need help with is identify which processors have drivers installed.  I need to verify that both x64 and x86 are installed.  
The query itself is:
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)

Thanks,
Steve
0
Comment
Question by:usmmsupport
  • 5
  • 4
10 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 33517388
Hi, if you run Microsoft's ScriptoMatic V2, you should be able to enumerate the Win32_PrinterDriver class, and pull out the required driver names from there.....

Would that help get you on the right track?

Regards,

Rob.
0
 

Author Comment

by:usmmsupport
ID: 33519966
The driver name will tell me which driver it's using, but it won't tell me which processors it's good for.  I need to enumerate which check boxes are selected when I click the Additional Drivers button on the Sharing tab.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 33528376
OK, after a stack of searching and trying different things, I finally plugged the right query into Google, and came up with this:
http://blogs.technet.com/b/heyscriptingguy/archive/2005/07/19/how-can-i-retrieve-information-about-the-printer-driver-used-by-a-printer.aspx

So, I have modified that code, and taken the approach at the bottom of that article, to get every driver name on a server, then output every printer that uses that driver.

Regards,

Rob.
If LCase(Right(Wscript.FullName, 11)) = "wscript.exe" Then

    strPath = Wscript.ScriptFullName

    strCommand = "%comspec% /k cscript  """ & strPath & """"

    Set objShell = CreateObject("Wscript.Shell")

    objShell.Run(strCommand), 1, True

    Wscript.Quit

End If



On Error Resume Next



Const wbemFlagReturnImmediately = &h10

Const wbemFlagForwardOnly = &h20



strComputer = "PRINTSERVER"



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

Set colDrivers = objWMIService.ExecQuery("SELECT Name FROM Win32_PrinterDriver", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)



For Each objDriver In colDrivers

	WScript.Echo VbCrLf & "Driver: " & objDriver.Name & VbCrLf & String(50, "=")

	Set colDevices = objWMIService.ExecQuery("Associators Of {Win32_PrinterDriver.Name='" & objDriver.Name & "'} WHERE AssocClass = Win32_DriverForDevice Role=Dependent")

	For Each objDevice In colDevices

	    Wscript.Echo "Name: " & objDevice.DeviceID & vbCrLf & "Share Name: " & objDevice.ShareName

	Next

Next

Open in new window

0
 

Author Comment

by:usmmsupport
ID: 33530972
This is much closer, but it appears that it lists out the x86 drivers, but doesn't put any printer names there.  It lists all the x64 ones properly.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 33536933
Hmmm, that's odd.  It list x86 drivers on my x86 systems.....can you try it on an x86 system?  I will see if I can try it on an x64 system...

Rob.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 33538743
I don't have any x64 print servers, and on a standard x64 system, I only have 64 bit drivers installed, so I can't replicate your issue.

I can't see why it wouldn't show the associated printers though....unless they have a different name....

On your 64 bit system, put this in a batch file
mshta C:\Temp\ScriptoMaticV2.hta

and download ScriptoMaticV2.hta from Microsoft to C:\Temp, then with the batch file, "Run As Administrator".  This will show the ScriptoMatic HTA.  On the right, select Win32_DriverForDevice and click Run.  Sift through that and see if the x86 links are there....

Regards,

Rob.
0
 

Author Comment

by:usmmsupport
ID: 33540736
Running that only shows the x64 drivers, no x86 drivers.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 33547701
OK, obvious question....are you sure you have some x86 drivers ticked for a printer or two?

Rob.
0
 

Author Closing Comment

by:usmmsupport
ID: 33681492
problem no longer relevant
0
 

Expert Comment

by:wtpritz
ID: 37881595
what a waste of time
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to add field in my script 2 31
1350 HP printer error - paper jam 8 31
Printing A1 on A4 Printer 8 110
Using an encrypted  value to decrypt and display contents in vb6 9 50
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
I wrote an article (http://www.experts-exchange.com/articles/2245/Anti-rootkit-software.html) some time ago with a reference to nLite  (http://www.nliteos.com/)slipstreaming software.  I recently changed that link to point to NTLite (https://www.ntl…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

26 Experts available now in Live!

Get 1:1 Help Now