【问题标题】:Getting the location of an inf from ManagementObjectSearcher从 ManagementObjectSearcher 获取 inf 的位置
【发布时间】:2012-06-25 19:20:05
【问题描述】:

我正在使用以下代码在 Windows 中遍历我的所有设备驱动程序。我能够找到 INF 名称,但是,我无法找到 INF 位置。任何帮助都很棒。

ManagementObjectSearcher searcher = 
            new ManagementObjectSearcher("SELECT * FROM Win32_PnPSignedDriver");
foreach (ManagementObject obj in searcher.Get())
{
    if(obj["DriverProviderName"] != null)
    {
        foreach (PropertyData prop in obj.Properties)
        {
            Console.WriteLine("{0}: {1}", prop.Name, prop.Value);
        }
    }
}

输出:InfName:hal.inf

hal.inf 的位置在哪里?我正在尝试创建一个可以备份所有设备驱动程序的应用程序。

Hal.inf 只是一个例子。

物业出口示例:

标题
ClassGuid {4D36E968-E325-11CE-BFC1-08002BE10318}
CompatID PCI\VEN_10DE&DEV_0422&REV_A1
创建类名
说明 NVIDIA GeForce 8400 GS
设备类显示
设备ID PCI\VEN_10DE&DEV_0422&SUBSYS_C7323842&REV_A1\4&31ADF711&0&0008
设备名称 NVIDIA GeForce 8400 GS
开发加载器
司机日期 20120515000000.******+***
司机姓名
DriverProviderName NVIDIA
驱动程序版本 6.14.13.142
友好名称
硬件 ID PCI\VEN_10DE&DEV_0422&SUBSYS_C7323842&REV_A1
InfName oem25.inf
安装日期
已签名为真
位置 PCI 总线 1,设备 0,功能 0
制造商 英伟达
姓名
PDO \设备\NTPNP_PCI0021
签名者 Microsoft Windows 硬件兼容性发布者
开始
启动模式
状态
系统创建类名
系统名称

【问题讨论】:

    标签: c# wmi


    【解决方案1】:

    如果我没记错的话,在安装驱动程序期间使用的 *.inf 会被转换为 Windows 的驱动程序存储区,即 oem[0-9]{1,3}.inf 文件,您会在输出中看到该文件.我刚刚使用 devcon 程序找到了我的视频卡 hwid,然后再次使用 devcon 列出了驱动程序文件。

    在输出中,您会注意到对 System32/DriverStore 的路径引用。这实际上包含安装期间使用的原始 *.inf 文件。 :) 它的 1:1 只是将 nv_disp.inf 与我的 oem#.inf 区分开来。 Devcon 确实为您提供了完整的驱动程序文件列表,这与我使用 wmi 和其他人的经验不同。

    这是我正在谈论的参考 C:\Windows\System32\DriverStore\FileRepository\nv_disp.inf_amd64_neutral_671aa18aef114cc2\

    所以它非常简单!抓住你的 HWID | devcon 驱动程序文件 |清理结果,添加一点点逻辑 | tar old-driver.tar filelist.txt

    使用这些备份进行恢复或做一些有用的事情将是非常不同的事情。每次更新驱动程序时,它都会添加一个新的驱动程序存储文件夹,找出哪个是最新的一点也不难。所以理论上你不需要通过获取一些文件夹统计数据并备份正确的数据来做任何事情。您也可以使用 PnPutil 循环并尝试删除所有 oem*.inf 驱动程序包,它无法删除活动包,因此风险很小,但它可能会稍微清理驱动程序库。

    您可能还对我在 github 上提供的 Geforce Driver Check 脚本感兴趣。

    您需要下载他们的 500meg Driver Dev Kit ISO 并提取+重命名两个 devcon 二进制文件(我认为是 devconx64.exe 和 devcon.exe)Devcon 可以执行“设备管理器 GUI”可以从 CMD 行执行的所有操作。

    $ devcon driverfiles PCI\\VEN_10DE\&DEV_1184
    PCI\VEN_10DE&DEV_1184&SUBSYS_37743842&REV_A1\4&2F1C4782&0&0018
        Name: NVIDIA GeForce GTX 770
        Driver installed from C:\Windows\INF\oem8.inf [Section090]. 53 file(s) used by driver:
            C:\Program Files\NVIDIA Corporation\Drs\dbInstaller.exe
            C:\Program Files\NVIDIA Corporation\Drs\nvdrsdb.bin
            C:\Windows\System32\DriverStore\FileRepository\nv_disp.inf_amd64_neutral_671aa18aef114cc2\NvCplSetupEng.exe
            C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\Nvd3d9wrap.dll
            C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\detoured.dll
            C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\nvdxgiwrap.dll
            C:\Program Files\NVIDIA Corporation\coprocmanager\Nvd3d9wrapx.dll
            C:\Program Files\NVIDIA Corporation\coprocmanager\detoured.dll
            C:\Program Files\NVIDIA Corporation\coprocmanager\nvdxgiwrapx.dll
            C:\Program Files\NVIDIA Corporation\license.txt
            C:\Program Files\NVIDIA Corporation\NVSMI\MCU.exe
            C:\Program Files\NVIDIA Corporation\NVSMI\nvdebugdump.exe
            C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.1.pdf
            C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.exe
            C:\Program Files\NVIDIA Corporation\NVSMI\nvml.dll
            C:\Program Files\NVIDIA Corporation\OpenCL\OpenCL.dll
            C:\Program Files\NVIDIA Corporation\OpenCL\OpenCL64.dll
            C:\Windows\system32\DRIVERS\nvlddmkm.sys
            C:\Windows\system32\NvFBC64.dll
            C:\Windows\system32\NvIFR64.dll
            C:\Windows\system32\NvIFROpenGL.dll
            C:\Windows\system32\nvEncodeAPI64.dll
            C:\Windows\system32\nvapi64.dll
            C:\Windows\system32\nvcompiler.dll
            C:\Windows\system32\nvcuda.dll
            C:\Windows\system32\nvcuvenc.dll
            C:\Windows\system32\nvcuvid.dll
            C:\Windows\system32\nvd3dumx.dll
            C:\Windows\system32\nvinfo.pb
            C:\Windows\system32\nvinitx.dll
            C:\Windows\system32\nvoglshim64.dll
            C:\Windows\system32\nvoglv64.dll
            C:\Windows\system32\nvopencl.dll
            C:\Windows\system32\nvumdshimx.dll
            C:\Windows\system32\nvwgf2umx.dll
            C:\Windows\SysWow64\NvFBC.dll
            C:\Windows\SysWow64\NvIFR.dll
            C:\Windows\SysWow64\NvIFROpenGL.dll
            C:\Windows\SysWow64\nvEncodeAPI.dll
            C:\Windows\SysWow64\nvapi.dll
            C:\Windows\SysWow64\nvcompiler.dll
            C:\Windows\SysWow64\nvcuda.dll
            C:\Windows\SysWow64\nvcuvenc.dll
            C:\Windows\SysWow64\nvcuvid.dll
            C:\Windows\SysWow64\nvd3dum.dll
            C:\Windows\SysWow64\nvinit.dll
            C:\Windows\SysWow64\nvoglshim32.dll
            C:\Windows\SysWow64\nvoglv32.dll
            C:\Windows\SysWow64\nvopencl.dll
            C:\Windows\SysWow64\nvumdshim.dll
            C:\Windows\SysWow64\nvwgf2um.dll
            C:\Windows\system32\nvdispco6433193.dll
            C:\Windows\system32\nvdispgenco6433193.dll
    1 matching device(s) found.
    
    Device Console Help:
    devcon.exe [-r] [-m:\\<machine>] <command> [<arg>...]
    -r           Reboots the system only when a restart or reboot is required.
    <machine>    Specifies a remote computer.
    <command>    Specifies a Devcon command (see command list below).
    <arg>...     One or more arguments that modify a command.
    For help with a specific command, type: devcon.exe help <command>
    classfilter          Add, delete, and reorder class filters.
    classes              List all device setup classes.
    disable              Disable devices.
    driverfiles          List installed driver files for devices.
    drivernodes          List driver nodes of devices.
    enable               Enable devices.
    find                 Find devices.
    findall              Find devices, including those that are not currently attached.
    help                 Display Devcon help.
    hwids                List hardware IDs of devices.
    install              Install a device manually.
    listclass            List all devices in a setup class.
    reboot               Reboot the local computer.
    remove               Remove devices.
    rescan               Scan for new hardware.
    resources            List hardware resources for devices.
    restart              Restart devices.
    sethwid              Modify Hardware ID's of listed root-enumerated devices.
    stack                List expected driver stack for devices.
    status               List running status of devices.
    update               Update a device manually.
    updateni             Manually update a device (non interactive).
    dp_add               Adds (installs) a third-party (OEM) driver package.
    dp_delete            Deletes a third-party (OEM) driver package.
    dp_enum              Lists the third-party (OEM) driver packages installed on this machine.
    

    【讨论】:

      【解决方案2】:

      要检索有关驱动程序文件本身的信息,请查询Win32_SystemDriver 表。驱动程序路径由PathName 属性给出。

      【讨论】:

      • 埃文,实际上并没有显示 INF
      • INF 应与 .inf 扩展名相同。
      • 埃文,你以前用过这个吗? Win32_PnPSignedDriverCIMDataFile 我想这就是我要找的,但我找不到例子
      • 表示实际数据文件内容:msdn.microsoft.com/en-us/library/windows/desktop/…
      • Win32_PnPSignedDriverCIMDataFile 关联 WMI 类查找与 PnP 驱动程序关联的所有二进制文件。
      猜你喜欢
      • 2015-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-17
      • 2012-05-27
      相关资源
      最近更新 更多