0

有什么方法或教程可以:

  1. 列出与驱动程序相关的所有文件
  2. 列出这些文件的文件版本(.exe、.dll、.sys 等)

我正在尝试编译计算机中安装的所有驱动程序的列表,主要列出与驱动程序相关的所有文件(exe、sys、dll 等)以及文件版本。请看附图。

图片链接:

我尝试使用 Wmi-Object (Powershell) 和 DevCon 工具,但可以列出这些文件。

使用 Powershell,我可以列出驱动程序名称,但只显示文件。

# Script to output all of the drivers installed in the computer

# Export all driver names to a text file
Get-WmiObject win32_SystemDriver | select name | foreach {$_.name} | Out-File C:\driverName.csv

# Read driver name from file.
$driver =  Get-Content "C:\driverName.csv"

# Get the file path of the driver
$path = (Get-WmiObject win32_SystemDriver | Where-Object name -match $driverName).PathName

# Extract information from the file path and export it to CSV
(Get-Item $path).VersionInfo  | Select FileDescription, ProductVersion, FileVersion, FileName | Export-Csv -Path C:\FileVersion.csv
4

3 回答 3

2

这是一个完全按照要求执行的 Powershell 脚本:

#
$hostname = $ENV:COMPUTERNAME

# Get Third Party drivers used, that are not provided by Microsoft and presumably included in the OS
$drivers = Get-WmiObject Win32_PNPSignedDriver | where {$_.DriverProviderName -ne "Microsoft"}

# Initialize the list of detected driver packages as an array
$DriverFolders = @()
foreach ($d in $drivers) {
    # We initialize the list of driver files for each driver
    $DriverFiles = @()
    # For each driver instance from WMI class Win32_PNPSignedDriver, we compose the related WMI object name from the other WMI driver class, Win32_PNPSignedDriverCIMDataFile
    $ModifiedDeviceID = $d.DeviceID -replace "\\", "\\"
    $Antecedent = "\\" + $hostname + "\ROOT\cimv2:Win32_PNPSignedDriver.DeviceID=""$ModifiedDeviceID"""
    # Get all related driver files for each driver listed in WMI class Win32_PNPSignedDriver
    $DriverFiles += Get-WmiObject Win32_PNPSignedDriverCIMDataFile | where {$_.Antecedent -eq $Antecedent}
    $DriverName = $d.DeviceName
    $DriverID = $d.DeviceID
    Write-Host "####Driver files for driver with name: $DriverName" -ForegroundColor Green
    Write-Host "and with DriverID: $DriverID" -ForegroundColor Green
    foreach ($i in $DriverFiles) {
            # We elliminate double backslashes from the file paths
            $path = $i.Dependent.Split("=")[1] -replace '\\\\', '\'
            $path2 = $path.Substring(1,$path.Length-2)
            $InfItem = Get-Item -Path $path2
            $Version = $InfItem.VersionInfo.FileVersion
            Write-Output "File: $path2"
            Write-Output "Version: $Version"
    }
    }
#

您可以从这里开始做更多的事情,甚至从系统检测到已安装和使用的文件中提取所有与驱动程序相关的文件。

可以在此处找到更复杂的脚本版本。

于 2016-11-02T21:03:50.967 回答
1

用户 DevCon 实用程序列出有关计算机中安装的所有驱动程序的信息。

  1. 从这里下载 DevCon 包:
  2. 解压包
  3. 以管理员身份打开 CMD并将目录更改为解压缩文件夹
  4. devcon.exe driverfiles *
  5. 它将列出计算机中安装的所有驱动程序、它们的硬件 ID、.inf 文件以及与该特定驱动程序关联的所有其他文件。
于 2015-07-01T16:13:30.927 回答
0
Get-WmiObject -Class Win32_SystemDriver | 
Select-Object Name,PathName,@{N='FileInfo';E={Get-Item -Path $_.pathname | Select-Object -ExpandProperty VersionInfo | Select-Object FileDescription, ProductVersion, FileVersion, FileName}}  | 
    Export-Clixml C:\temp\drivers.xml

$ImportedXML = Import-Clixml -Path C:\temp\drivers.xml

$ImportedXML | Where-Object Name -eq '3ware' | Select-Object -ExpandProperty fileinfo

由于您要查找的信息隐藏在嵌套属性下,因此您无法将结构导出到诸如“CSV”之类的平面文件中,除非进行一些自定义。无论如何,更好的选择是将输出存储在 xml 文件中,如上所示,并在需要时检索信息。

于 2015-06-23T03:01:50.260 回答