Jump to content

List Plug and Play Signed Drivers


Recommended Posts

Is this Vbs script converatble to autoit script ?

the script

Returns information about the signed plug and play drivers installed on a computer.

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

Set colItems = objWMIService.ExecQuery("Select * from Win32_PnPSignedDriver")

For Each objItem in colItems
    Wscript.Echo "Class Guid: " & objItem.ClassGuid
    Wscript.Echo "Compatability ID: " & objItem.CompatID
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device Class: " & objItem.DeviceClass
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Device Name: " & objItem.DeviceName
    dtmWMIDate = objItem.DriverDate
    strReturn = WMIDateStringToDate(dtmWMIDate)
    Wscript.Echo "Driver Date: " & strReturn
    Wscript.Echo "Driver Provider Name: " & objItem.DriverProviderName
    Wscript.Echo "Driver Version: " & objItem.DriverVersion
    Wscript.Echo "Hardware ID: " & objItem.HardWareID
    Wscript.Echo "INF Name: " & objItem.InfName
    Wscript.Echo "Is Signed: " & objItem.IsSigned
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "PDO: " & objItem.PDO
    Wscript.Echo "Signer: " & objItem.Signer
    Wscript.Echo
Next
 
Function WMIDateStringToDate(dtmWMIDate)
    If Not IsNull(dtmWMIDate) Then
    WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _
         Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
             & " " & Mid (dtmWMIDate, 9, 2) & ":" & _
                 Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate,13, 2))
    End If
End Function
Link to comment
Share on other sites

Probably. Take a look at this and see how similar they are.

I am getting trouble with Converting the vbs function to autoit , which is

Function WMIDateStringToDate(dtmWMIDate)
    If Not IsNull(dtmWMIDate) Then
    WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _
         Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
             & " " & Mid (dtmWMIDate, 9, 2) & ":" & _
                 Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate,13, 2))
    End If
End Function
Link to comment
Share on other sites

  • 3 months later...

I had to do this for one of my own scripts, and translated it thusly, listing all PnP drivers:

$sFile = @ScriptDir & "\DriverList.txt"
$hFile = FileOpen($sFile, 2) ; 2 = overwrite

$oCimV2 = ObjGet("WinMgmts:\\" & @ComputerName & "\root\CimV2")
If IsObj($oCimV2) Then
    $sQuery = "Select * From Win32_PnPSignedDriver"
    $colDrivers = $oCimV2.ExecQuery ($sQuery)
    If IsObj($colDrivers) Then
        $n = 0
        For $oDriver In $colDrivers
            $sMsg = "Driver " & $n & ": "
            $sMsg &= @CRLF & @TAB & "Class Guid: " & $oDriver.ClassGuid
            $sMsg &= @CRLF & @TAB & "Compatability ID: " & $oDriver.CompatID
            $sMsg &= @CRLF & @TAB & "Description: " & $oDriver.Description
            $sMsg &= @CRLF & @TAB & "Device Class: " & $oDriver.DeviceClass
            $sMsg &= @CRLF & @TAB & "Device ID: " & $oDriver.DeviceID
            $sMsg &= @CRLF & @TAB & "Device Name: " & $oDriver.DeviceName
            $sMsg &= @CRLF & @TAB & "Driver Provider Name: " & $oDriver.DriverProviderName
            $sMsg &= @CRLF & @TAB & "Driver Version: " & $oDriver.DriverVersion
            $sWMIDate = $oDriver.DriverDate
            $sWMIDate = _WMIDateStringToDate($sWMIDate)
            $sMsg &= @CRLF & @TAB & "Driver Date: " & $sWMIDate
            $sMsg &= @CRLF & @TAB & "HardWare ID: " & $oDriver.HardWareID
            $sMsg &= @CRLF & @TAB & "Inf Name: " & $oDriver.InfName
            $sMsg &= @CRLF & @TAB & "Is Signed: " & $oDriver.IsSigned
            $sMsg &= @CRLF & @TAB & "Manufacturer: " & $oDriver.Manufacturer
            $sMsg &= @CRLF & @TAB & "PDO: " & $oDriver.PDO
            $sMsg &= @CRLF & @TAB & "Signer: " & $oDriver.Signer
            FileWrite($hFile, $sMsg & @CRLF & @CRLF)
            $n += 1
        Next
    Else
        ConsoleWrite("Debug: $colDrivers is not an object." & @LF)
    EndIf
Else
    ConsoleWrite("Debug: $oCimV2 is not an object." & @LF)
EndIf

FileClose($hFile)
Run("notepad.exe " & $sFile)


Func _WMIDateStringToDate($dtmWMIDate)
    If StringLen($dtmWMIDate) >= 15 Then
        Local $RET = StringMid($dtmWMIDate, 5, 2) & "/" & StringMid($dtmWMIDate, 7, 2) & "/" & StringLeft($dtmWMIDate, 4) & " " & _
                StringMid($dtmWMIDate, 9, 2) & ":" & StringMid($dtmWMIDate, 11, 2) & ":" & StringMid($dtmWMIDate, 13, 2)
        Return $RET
    Else
        Return 0
    EndIf
EndFunc   ;==>_WMIDateStringToDate

I didn't try to translate the VB CDate() function, because the date string generated looks right to me (being all numeric, language is not an issue).

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...