Discussion:
WMI driver version
(too old to reply)
k***@gmail.com
2009-03-26 01:47:04 UTC
Permalink
Hi
I need to find out the driver version of all the devices on my
computer
however, I use Win32_SystemDriver but it doesnt give driver version
Is there a way allows me to find out the driver version?
Ruediger Roesler
2009-03-28 03:16:31 UTC
Permalink
Post by k***@gmail.com
I need to find out the driver version of all the devices on my
computer
however, I use Win32_SystemDriver but it doesnt give driver version
Is there a way allows me to find out the driver version?
Then you must just search and try! If you mean to have found a class,
you are able to do it with this script for testing to get out the
properties:

'########################### QueryWMI.vbs #############################

If WScript.Arguments.Count > 0 Then
strClass = WScript.Arguments(0)
Else
strClass = InputBox ("Enter a WMI-class!", "WMI query", _
"Win32_PnPSignedDriver")
End If

Set wmi = GetObject("winmgmts:")

For Each wmiInst in wmi.InstancesOf(strClass)
WScript.Echo wmiInst.getObjectText_
Next
'########################### QueryWMI.vbs #############################

Or you immediately write a script which displays the essential
information:

'###################### ListSignedDriver.vbs ##########################

Set wmi = GetObject("winmgmts:")

For Each wmiDrv in wmi.ExecQuery("Select * from Win32_PnPSignedDriver")
WScript.Echo "Device Name: " & wmiDrv.DeviceName
WScript.Echo "Is Signed: " & wmiDrv.IsSigned
WScript.Echo "Driver Date: " & Convert(wmiDrv.DriverDate)
WScript.Echo "Driver Version: " & wmiDrv.DriverVersion
WScript.Echo "Device ID: " & wmiDrv.DeviceID & vbCRLF
Next

Function Convert(strDate) ' Format: 20070531000000.******+***
If IsNull(strDate) Then Exit Function
Convert = CDate(Mid(strDate, 5, 2) & "/" & _
Mid(strDate, 7, 2) & "/" & _
Left(strDate, 4) & " " & _
Mid (strDate, 9, 2) & ":" & _
Mid(strDate, 11, 2) & ":" & _
Mid(strDate,13, 2))
End Function
'####################### ListSignedDriver.vbs ##########################

To list all classes, this algorithm assists:

'########################### WMIClass.vbs #############################
Option Explicit

Const NSPACE = "__NAMESPACE", ROOT = "\\.\Root"
Dim wmi, fso, wmiNameSpace

Set wmi = GetObject("winmgmts:" & ROOT)

WScript.Echo "These are the top namespaces:"
For Each wmiNameSpace In wmi.InstancesOf(NSPACE)
WScript.Echo Space(10) & wmiNameSpace.Name
Next
WScript.Sleep 10000

Call EnumNameSpace(ROOT)

Sub EnumNameSpace(strPaNameSpace) ' recurse through the namespaces
Dim wmi, wmiClass, wmiNameSpace, wmiSvc, str

Set wmi = GetObject("winmgmts:" & strPaNameSpace)

For Each wmiNameSpace In wmi.Execquery("select * from " & NSPACE)
str = wmiNameSpace.Path_.Namespace & "\" & wmiNameSpace.Name
WScript.Echo vbCRLF & str & ":"
Set wmiSvc = GetObject("winmgmts:" & str)
For Each wmiClass In wmiSvc.SubclassesOf()
WScript.Echo Space(4) & wmiClass.Path_.Relpath
Next
Call EnumNameSpace(str)
Next
End Sub
'########################### WMIClass.vbs #############################
--
ЯR
k***@gmail.com
2009-03-28 08:58:53 UTC
Permalink
Hi
Thank you very much for replying my post
some part of your script I am having trouble to understand, would it
be possible for you to send me a script the runs?

appreciate your help

Thanks
Kelly
Ruediger Roesler
2009-03-28 13:02:51 UTC
Permalink
Post by k***@gmail.com
Thank you very much for replying my post
some part of your script I am having trouble to understand, would it
be possible for you to send me a script the runs?
All of my scripts run at least with Windows XP and Service Pack 3 on
every PC. If you have any question, you can ask here in the public, and
I will try to reply to it here in this group.

Nevertheless and unfortunately, I am not able to grant free support or
outside help to private and unfamiliar fellow beings. I don't even know
your correct name or the region from which you have written.

*How to Use the Microsoft Product Support Newsgroups*
http://support.microsoft.com/gp/newswhelp

The directions for use in this subscription apply in principle to all
other groups:
http://www.microsoft.com/Windows/ie/community/columns/newsgroups101.mspx

| *How to ask a question*

| When posting questions to a professional forum or newsgroup it is
| vital to format the question and it's content in a proper way in order
| to greatly increase the possibility for quickly receiving a good
| answer, and thus saving you time and frustration.
http://support.microsoft.com/kb/555375/

*Karaitiana N Taiuru*:
http://www.taiuru.maori.nz/publications/dictionary/n.html
;-)
--
ЯR
mayayana
2009-03-28 16:25:40 UTC
Permalink
I don't know whether this is the best method
for your needs, but it might help:

'------------------------------------------ .vbs script ---------
Dim s2, Ob, Col, WMI

Set WMI = GetObject("WinMgmts:")
Set Col = WMI.ExecQuery("Select * from Win32_VideoController")

For Each Ob in Col
s2 = s2 & "Description: " & Ob.Description & vbCrLf
s2 = s2 & "Name: " & Ob.Name & vbCrLf
i2 = Ob.AdapterRAM
If i2 > 0 Then
i2 = i2 \ 1024 \ 1024
s2 = s2 & "RAM: " & " MB" & vbCrLf
End If
s2 = s2 & "Driver Date: " & Ob.DriverDate & vbCrLf
s2 = s2 & "Driver Version: " & Ob.DriverVersion & vbCrLf
Next

Set Col = Nothing
Set WMI = Nothing

MsgBox s2
'----------------------------

That shows a description of your display adapter and
driver version. It takes the approach of just looking for
relevant hardware rather than listing all drivers. It's the
opposite approach from what Ruediger Roesler posted.
Instead of getting all drivers it's getting specific drivers.
In general there are very few things that actually need
drivers, so this method might make sense.

The disadvantage is that you have to look
through the objects and properties available. For instance,
Win32_SoundDevice doesn't have a driver version
property, so I don't know how one returns that. maybe
that will come under Win32_OnBoardDevice? I don't
know. Unfortunately, WMI is a mess of poorly designed
object structures. There's nothing you can do about that.

I'm not familiar with Win32_PnPSignedDriver or
Win32_SystemDriver. There might be advantages to those
methods. (Though I don't see why one would want to exclude
any driver simply on the basis that it's not signed.)
Post by k***@gmail.com
Thank you very much for replying my post
some part of your script I am having trouble to understand, would it
be possible for you to send me a script the runs?
appreciate your help
Thanks
Kelly
Ruediger Roesler
2009-03-28 23:35:05 UTC
Permalink
Post by mayayana
The disadvantage is that you have to look
through the objects and properties available. For instance,
Win32_SoundDevice doesn't have a driver version
property, so I don't know how one returns that. maybe
that will come under Win32_OnBoardDevice? I don't
know. Unfortunately, WMI is a mess of poorly designed
object structures. There's nothing you can do about that.
I'm not familiar with Win32_PnPSignedDriver or
Win32_SystemDriver. There might be advantages to those
methods. (Though I don't see why one would want to exclude
any driver simply on the basis that it's not signed.)
I admit, the WMI is a little bit heavy to understand, but an amount can
be employed with thus. :-) For example, such a thing here:

'###################### ListSignedDriver.vbs ##########################
Option Explicit
' You have to execute this script only with CScript as host at the
' Command Prompt, e.g.:
' CScript.exe <Path to Script>\ListSignedDriver.vbs
' CScript.exe C:\Windows\ListSignedDriver.vbs
' It is possible to search for a driver with a keyword, e.g.:
' CScript.exe C:\Windows\ListSignedDriver.vbs Audio

Dim strOpt, wmi

If WScript.Arguments.Count > 0 Then
strOpt = WScript.Arguments(0)
End If

Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!" & _
"root\cimv2")

WScript.Stdout.WriteLine vbCRLF & "Searching for Drivers with " & _
strOpt & ":" & vbCRLF & "(plz wait a minute!)" & vbCRLF
WScript.Stdout.WriteLine FindDrvr(strOpt)

Function FindDrvr(strFind)
Dim wmiDrvr, str, i

For Each wmiDrvr in wmi.ExecQuery("Select * from " & _
"Win32_PnPSignedDriver")
If InStr(1, wmiDrvr.DeviceName, strFind, vbTextCompare) > 0 Then
i = i + 1
str = str & vbCRLF & vbCRLF
str = str & Printf("Device Name", wmiDrvr.DeviceName)
If wmiDrvr.IsSigned Then
str = str & vbCRLF & Printf("Signer", wmiDrvr.Signer)
End If
str = str & vbCRLF
str = str & Printf("Driver Name", wmiDrvr.DriverName)
str = str & vbCRLF & Printf("Inf-Name", wmiDrvr.InfName)
str = str & vbCRLF & Printf("Driver Date", _
Convert(wmiDrvr.DriverDate))
str = str & vbCRLF & Printf("Location", wmiDrvr.Location)
str = str & vbCRLF
str = str & Printf("Driver Vers", wmiDrvr.DriverVersion)
str = str & vbCRLF & Printf("Device ID", wmiDrvr.DeviceID)
str = str & vbCRLF & vbCRLF
End If
Next
If IsEmpty(str) Then Exit Function

FindDrvr = vbCRLF & "There were " & i & " drivers found:" & str
End Function

Function Convert(strDate) ' Format: 20070531000000.******+***
If IsNull(strDate) Then Exit Function
Convert = CDate(Mid(strDate, 5, 2) & "/" & _
Mid(strDate, 7, 2) & "/" & _
Left(strDate, 4) & " " & _
Mid (strDate, 9, 2) & ":" & _
Mid(strDate, 11, 2) & ":" & _
Mid(strDate,13, 2))
End Function

Function Printf(strTxt, strVal)
Const RAUM = 15

If IsNull(strVal) Then strVal = "(Null)"
If Len(strTxt) < RAUM Then
strTxt = strTxt & Space(RAUM - Len(strTxt) - 2)
End If

Printf = strTxt & ": " & strVal
End Function
'####################### ListSignedDriver.vbs ##########################

If you execute this script at the command line with a command like this:
CScript.exe ListSignedDriver.vbs Audio
you will get all the audio-drivers of your system. However, you have to
provide the path to the script, so that CScript will find it.
http://en.wikipedia.org/wiki/Command_Prompt_(Windows)

Of course alternatively this command can be executed before, so that
CScript is declared to the standard host for script processing:

WScript.exe //H:CScript //I //NoLogo //S

You will get additional help with this command, I suppose, *you* are
knowing that all, other people who read this maybe not and thus only for
them I have written that:
CScript.exe //?
or
WScript.exe //?

But, actually, everybody which seriously deals with the WMI should know
this.
--
ЯR
Ruediger Roesler
2009-03-29 01:08:26 UTC
Permalink
Post by Ruediger Roesler
http://en.wikipedia.org/wiki/Command_Prompt_(Windows)
Sorry for the broken link. I suppose, this one should be better:
http://en.wikipedia.org/wiki/Command_Prompt_(Windows)#Versions
--
ЯR
mayayana
2009-03-29 16:17:44 UTC
Permalink
That might work well, but I think there are at least
two caveats that people should be aware of:

1) Win32_PnPSignedDriver is only available on XP+.
I didn't realize that when you first posted it, but when
I didn't find Win32_PnPSignedDriver in my WMI help
file I went looking. I'm on 98SE, so it's no good to me --
or to anyone on 2000/ME.

2) I still question why one would want to be limited to
signed drivers when there are other methods to return driver
versions. It seems to be a situation similar to the installed
software functions of WMI: Microsoft unilaterally imposed a
standard, which they may or may not even follow themselves,
and then built it into WMI, pretending that it was universal.

To explain: WMI installed software only lists programs
installed via MSI, which is a very tedious method that Microsoft
themselves often don't use. So the installed software functions
are pretty much useless because they don't report the majority of
software installed. And of what is reported, one can get more info.
by just going directly through WindowsInstaller.Installer. So the
WMI functions for that are just a useless wrapper. But MS wants
to pretend that MSI is the only way to install software, so they
had to make the WMI functions useless in order to "save face".

In the same way, a lot of hardware companies didn't cooperate
with Microsoft's driver signing push at first. It may be that some still
don't. So listing only signed drivers would seem to be slightly
undependable at best.
Post by Ruediger Roesler
'###################### ListSignedDriver.vbs ##########################
Option Explicit
' You have to execute this script only with CScript as host at the
' CScript.exe <Path to Script>\ListSignedDriver.vbs
' CScript.exe C:\Windows\ListSignedDriver.vbs
' CScript.exe C:\Windows\ListSignedDriver.vbs Audio
Dim strOpt, wmi
If WScript.Arguments.Count > 0 Then
strOpt = WScript.Arguments(0)
End If
Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!" & _
"root\cimv2")
WScript.Stdout.WriteLine vbCRLF & "Searching for Drivers with " & _
strOpt & ":" & vbCRLF & "(plz wait a minute!)" & vbCRLF
WScript.Stdout.WriteLine FindDrvr(strOpt)
Function FindDrvr(strFind)
Dim wmiDrvr, str, i
For Each wmiDrvr in wmi.ExecQuery("Select * from " & _
"Win32_PnPSignedDriver")
If InStr(1, wmiDrvr.DeviceName, strFind, vbTextCompare) > 0 Then
i = i + 1
str = str & vbCRLF & vbCRLF
str = str & Printf("Device Name", wmiDrvr.DeviceName)
If wmiDrvr.IsSigned Then
str = str & vbCRLF & Printf("Signer", wmiDrvr.Signer)
End If
str = str & vbCRLF
str = str & Printf("Driver Name", wmiDrvr.DriverName)
str = str & vbCRLF & Printf("Inf-Name", wmiDrvr.InfName)
str = str & vbCRLF & Printf("Driver Date", _
Convert(wmiDrvr.DriverDate))
str = str & vbCRLF & Printf("Location", wmiDrvr.Location)
str = str & vbCRLF
str = str & Printf("Driver Vers", wmiDrvr.DriverVersion)
str = str & vbCRLF & Printf("Device ID", wmiDrvr.DeviceID)
str = str & vbCRLF & vbCRLF
End If
Next
If IsEmpty(str) Then Exit Function
FindDrvr = vbCRLF & "There were " & i & " drivers found:" & str
End Function
Function Convert(strDate) ' Format: 20070531000000.******+***
If IsNull(strDate) Then Exit Function
Convert = CDate(Mid(strDate, 5, 2) & "/" & _
Mid(strDate, 7, 2) & "/" & _
Left(strDate, 4) & " " & _
Mid (strDate, 9, 2) & ":" & _
Mid(strDate, 11, 2) & ":" & _
Mid(strDate,13, 2))
End Function
Function Printf(strTxt, strVal)
Const RAUM = 15
If IsNull(strVal) Then strVal = "(Null)"
If Len(strTxt) < RAUM Then
strTxt = strTxt & Space(RAUM - Len(strTxt) - 2)
End If
Printf = strTxt & ": " & strVal
End Function
'####################### ListSignedDriver.vbs ##########################
CScript.exe ListSignedDriver.vbs Audio
you will get all the audio-drivers of your system. However, you have to
provide the path to the script, so that CScript will find it.
http://en.wikipedia.org/wiki/Command_Prompt_(Windows)
Of course alternatively this command can be executed before, so that
WScript.exe file://H:CScript file://I file://NoLogo file://S
You will get additional help with this command, I suppose, *you* are
knowing that all, other people who read this maybe not and thus only for
CScript.exe //?
or
WScript.exe //?
But, actually, everybody which seriously deals with the WMI should know
this.
--
?R
Ruediger Roesler
2009-03-30 00:00:00 UTC
Permalink
Post by mayayana
That might work well, but I think there are at least
1) Win32_PnPSignedDriver is only available on XP+.
I didn't realize that when you first posted it, but when
I didn't find Win32_PnPSignedDriver in my WMI help
file I went looking. I'm on 98SE, so it's no good to me --
or to anyone on 2000/ME.
Yeah, you are right! U are from the US? Look here:


This is Bob Dylan, a great poet, composer and musician, and that are
Peter, Paul & Mary: ;-)


These were still times, they could still sing!
Post by mayayana
2) I still question why one would want to be limited to
signed drivers when there are other methods to return driver
versions. It seems to be a situation similar to the installed
software functions of WMI: Microsoft unilaterally imposed a
standard, which they may or may not even follow themselves,
and then built it into WMI, pretending that it was universal.
That it is not exactly: The OP asked for "the driver version of all the
devices on my computer" and the WMI-Method delivers exactly such things.
He did not tell anything about the Windows version. The
Win32_PnPSignedDriver-method determines all plug-and-play device
drivers, no matter wether they are signed or not. The reason for
crashing the OS was earlier incompatible such drivers and often not the
OS, but all people thought that it did that.
Post by mayayana
To explain: WMI installed software only lists programs
installed via MSI, which is a very tedious method that Microsoft
themselves often don't use. So the installed software functions
are pretty much useless because they don't report the majority of
software installed. And of what is reported, one can get more info.
by just going directly through WindowsInstaller.Installer. So the
WMI functions for that are just a useless wrapper. But MS wants
to pretend that MSI is the only way to install software, so they
had to make the WMI functions useless in order to "save face".
Sorry, I can understand that you are annoyed, but this is an other
problem that does not belongs to ours just now.
Post by mayayana
In the same way, a lot of hardware companies didn't cooperate
with Microsoft's driver signing push at first. It may be that some
still don't. So listing only signed drivers would seem to be slightly
undependable at best.
No, the method Win32_PnPSignedDriver lists all device drivers. It
delivers only either they are signed or not. The method
Win32_SystemDriver is for *system* *drivers*, sometimes they are for
devices, sometimes they assist *some* devices. This is a little but
important difference! A system driver can offer services for different
devices at the same time, e.g. a file system driver, a device driver is
only for interacting with exactly defined hardware, e.g. hard disks or
graphics devices.

This is a script for System Drivers and it displayes the file version of
the driver if avaílable with *two* different methods:

'######################### SystemDriver.vbs ###########################
Option Explicit
' It is recommended to execute this script with CScript as host at the
' command prompt:
' CScript.exe <Path to Script>\SystemDriver.vbs
' CScript.exe C:\Windows\SystemDriver.vbs

Dim wmi, wmiInst, i, str

Set wmi = GetObject("winmgmts:root\cimv2")

For Each wmiInst In wmi.InstancesOf("Win32_SystemDriver")
With wmiInst
i = i + 1
WScript.Echo vbCRLF & "DisplayName: " & .DisplayName
WScript.Echo "Name: " & .Name
WScript.Echo "Started: " & .Started
WScript.Echo "StartMode: " & .StartMode
WScript.Echo "ServiceType: " & .ServiceType
WScript.Echo "State: " & .State
If Not(IsNull(.PathName)) Then
str = RemoveIllChar(.PathName)
WScript.Echo "PathName: " & str
WScript.Echo "File Version: " & GetVersion(str)
With CreateObject("Scripting.FileSystemObject")
WScript.Echo "FSO File Version: " & .GetFileVersion(str)
End With
End If
WScript.Echo "DesktopInteract: " & .DesktopInteract
WScript.Echo "AcceptPause: " & .AcceptPause
WScript.Echo "AcceptStop: " & .AcceptStop
WScript.Echo "ErrorControl: " & .ErrorControl
WScript.Echo "ExitCode: " & .ExitCode
WScript.Echo "ServiceSpecificExitCode: " & _
.ServiceSpecificExitCode
WScript.Echo "Status: " & .Status
WScript.Echo "TagId: " & .TagId
'WScript.Echo "SystemName: " & .SystemName
WScript.Echo String(72, "#")
End With
Next

WScript.Echo vbCRLF & i & " system drivers were found."

Function RemoveIllChar(strPfad)
Const ILL = "\??\"

If InStr(strPfad, ILL) > 0 Then
strPfad = Right(strPfad, Len(strPfad) - (InStr(strPfad, ILL) +_
Len(ILL) - 1))
End if

RemoveIllChar = strPfad
End Function

Function GetVersion(strPath)
Dim objFile

For Each objFile In wmi.ExecQuery("select * from CIM_Datafile" & _
" where Name = '" & Replace(strPath, "\", "\\") & "'")
GetVersion = objFile.Version
Next
End Function
--
ЯR
mayayana
2009-03-30 03:54:24 UTC
Permalink
Post by Ruediger Roesler
Post by mayayana
1) Win32_PnPSignedDriver is only available on XP+.
I didn't realize that when you first posted it, but when
I didn't find Win32_PnPSignedDriver in my WMI help
file I went looking. I'm on 98SE, so it's no good to me --
or to anyone on 2000/ME.
http://youtu.be/wgECKj9LSH4
This is Bob Dylan, a great poet, composer and musician, and that are
Peter, Paul & Mary: ;-)
http://youtu.be/R0bFTq0Ivgk
These were still times, they could still sing!
Sorry but I don't understand what you're saying there.
Post by Ruediger Roesler
No, the method Win32_PnPSignedDriver lists all device drivers. It
delivers only either they are signed or not.
That's interesting to know. The name is misleading.

Loading...