Re: Enumerating System Drivers by Jim
Jim
Fri May 02 12:33:42 CDT 2008
On May 2, 12:38=A0pm, urkec <ur...@discussions.microsoft.com> wrote:
> "Jim Gregg" wrote:
> > Can anyone tel me if there is a way to enumerate system drivers and
> > their state against a list of remote computers? This would be the same
> > information you see when running WINMSD on a server. I am looking for
> > the existence of a particular driver and whether it is loaded and
> > running. I believe I can utilize the driverquery command and then
> > parse that but I was hoping for some method using only vbscript and/or
> > WMI. Thank you.
>
> There is Win32_SystemDriver class. This script lists all instances on a
> local computer:
>
> strComputer =3D "."
> Set objWMIService =3D GetObject _
> ("winmgmts:\\" & strComputer & "\root\cimv2")
>
> Set colSysDrivers =3D objWMIService.ExecQuery _
> ("Select * From Win32_SystemDriver")
>
> For Each objSysDriver In colSysDrivers
>
> WScript.Echo "Name: " & objSysDriver.Name
> WScript.Echo "Description: " & objSysDriver.Description
> WScript.Echo "File: " & objSysDriver.PathName
> WScript.Echo "Type: " & objSysDriver.ServiceType
> WScript.Echo "Started: " & CStr(objSysDriver.Started)
> WScript.Echo "Start mode: " & objSysDriver.StartMode
> WScript.Echo "State: " & objSysDriver.State
> WScript.Echo "Status: " & objSysDriver.Status
> WScript.Echo "Error control: " & objSysDriver.ErrorControl
> WScript.Echo "Accept pause: " & CStr(objSysDriver.AcceptPause)
> WScript.Echo "Accept stop: " & CStr(objSysDriver.AcceptStop)
> WScript.Echo
>
> Next
>
> If you need to query multiple computers you can put the list in an array o=
r
> read it from a file. You can specify the driver name in the query:
>
> strDriverName =3D "tcpip"
> arrComputers =3D Array("computer1", "computer2", "computer3")
>
> For Each strComputer In arrComputers
>
> Set objWMIService =3D GetObject _
> ("winmgmts:\\" & strComputer & "\root\cimv2")
>
> Set colSysDrivers =3D objWMIService.ExecQuery _
> ("Select * From Win32_SystemDriver " _
> & "Where Name =3D '" & strDriverName & "'")
>
> WScript.Echo "Instance count: " & colSysDrivers.Count
> WScript.Echo
>
> For Each objSysDriver In colSysDrivers
>
> WScript.Echo "Name: " & objSysDriver.Name
> WScript.Echo "Description: " & objSysDriver.Description
> WScript.Echo "File: " & objSysDriver.PathName
> WScript.Echo "Type: " & objSysDriver.ServiceType
> WScript.Echo "Started: " & CStr(objSysDriver.Started)
> WScript.Echo "Start mode: " & objSysDriver.StartMode
> WScript.Echo "State: " & objSysDriver.State
> WScript.Echo "Status: " & objSysDriver.Status
> WScript.Echo "Error control: " & objSysDriver.ErrorControl
> WScript.Echo "Accept pause: " & CStr(objSysDriver.AcceptPause)
> WScript.Echo "Accept stop: " & CStr(objSysDriver.AcceptStop)
>
> Next
>
> Next
>
> --
> urkec
That is exactly what I needed. Thank you.