Andie2302
Andie2302

Reputation: 4897

How to get a driver list in Windows?

What is the best way to create a list of all locally installed drivers with C# and the .net Framework?

It should work for Vista based Windows versions.

The list should contain:

Any suggestions / help is appreciated.

Till now I have found a wmi query: that points to the right direction.
Win32_PnPSignedDriver class ("Select * from Win32_PnPSignedDriver")

Upvotes: 0

Views: 3819

Answers (2)

Andie2302
Andie2302

Reputation: 4897

To get a list of drivers use the powershell script:

Get-WmiObject -Class "Win32_PnPSignedDriver" | Select  Caption, Description, DeviceID, DeviceClass, DriverVersion, DriverDate, DriverProviderName, InfName

To get a list of driver paths use the powershell script:

Get-WmiObject -Class "Win32_PnPSignedDriverCIMDataFile" | Select Dependent| foreach {
$y = $_ -match '(?<=")(.*?)(?=")'
$Matches[0]
}

At the moment i am just not sure if there are other drivers that this query doesn't match.


To use Powershell in C# use: System.Management.Automation

Upvotes: 1

GalacticJello
GalacticJello

Reputation: 11445

This should get you started:

    SelectQuery query = new System.Management.SelectQuery(
        "select name, pathname from Win32_Service");
    using (ManagementObjectSearcher searcher =
        new System.Management.ManagementObjectSearcher(query))
    {
        foreach (ManagementObject service in searcher.Get())
        {
            Console.WriteLine(string.Format(
                "Name: {0}\tPath : {1}", service["Name"], service["pathname"]));
        }
    }

Upvotes: 1

Related Questions