列表驱动程序相关的文件和它们的版本
问题描述:
有什么办法或教程在那里我可以:列表驱动程序相关的文件和它们的版本
- 列出所有相关的驱动程序
- 这些文件的列表文件版本的文件的文件(.exe,.dll文件,.sys等)
我想编译所有安装在计算机中的驱动程序的列表,并主要列出所有与驱动程序有关的文件(exe,sys,dll等)以及文件版本。请看附图。
我试图用的WMI对象(PowerShell的)和开发者大会工具,但可以得到上市的那些文件。
使用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
答
用户DevCon实用程序列出有关计算机中安装的所有驱动程序的信息。
- 下载开发者大会包从here:
- 解压缩包
- 打开CMD为管理员并将目录更改为解压缩文件夹
- 运行
devcon.exe driverfiles *
- 它会列出所有已安装的驱动程序计算机,其硬件ID,.INF文件以及与该特定驱动程序关联的所有其他文件。
答
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文件中,并在需要时检索信息。
答
这里是一个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"
}
}
#
你可以从这个做更多的事情出发,甚至从这些检测为提取出所有的驱动程序相关的文件由系统安装和使用。
更复杂的脚本版本可以找到here。
+0
我喜欢这个解决方案,对于那些执行它有困难的人(在这个系统上禁止执行脚本),这里是答案http://stackoverflow.com/a/4038991/ – feelthhis
谢谢!但我试图列出与驱动程序相关的所有文件。 – Imsa
好吧,我想你将不得不使用devcon并使用正则表达式解析其输出,这将需要做一些事情。或者将所有驱动程序导出到临时文件夹,然后进入该文件夹并列出每个驱动程序及其使用的文件 – Kiran
如何将所有安装的驱动程序及其文件一起导出/备份到文件夹? 谢谢! – Imsa