2015-06-22 26 views
0

有什麼辦法或教程在那裏我可以:列表驅動程序相關的文件和它們的版本

  1. 列出所有相關的驅動程序
  2. 這些文件的列表文件版本的文件的文件(.exe,.dll文件,.sys等)

我想編譯所有安裝在計算機中的驅動程序的列表,並主要列出所有與驅動程序有關的文件(exe,sys,dll等)以及文件版本。請看附圖。

Link to picture:

我試圖用的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 

回答

1

用戶DevCon實用程序列出有關計算機中安裝的所有驅動程序的信息。

  1. 下載開發者大會包從here
  2. 解壓縮包
  3. 打開CMD爲管理員並將目錄更改爲解壓縮文件夾
  4. 運行devcon.exe driverfiles *
  5. 它會列出所有已安裝的驅動程序計算機,其硬件ID,.INF文件以及與該特定驅動程序關聯的所有其他文件。
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文件中,並在需要時檢索信息。

+0

謝謝!但我試圖列出與驅動程序相關的所有文件。 – Imsa

+0

好吧,我想你將不得不使用devcon並使用正則表達式解析其輸出,這將需要做一些事情。或者將所有驅動程序導出到臨時文件夾,然後進入該文件夾並列出每個驅動程序及其使用的文件 – Kiran

+0

如何將所有安裝的驅動程序及其文件一起導出/備份到文件夾? 謝謝! – Imsa

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" 
    } 
    } 

你可以從這個做更多的事情出發,甚至從這些檢測爲提取出所有的驅動程序相關的文件由系統安裝和使用。

更復雜的腳本版本可以找到here

+0

我喜歡這個解決方案,對於那些執行它有困難的人(在這個系統上禁止執行腳本),這裏是答案http://stackoverflow.com/a/4038991/ – feelthhis

相關問題