2

操作系统:Windows Server 2016 R2

我有一个 RAMDisk 驱动程序可以使用“添加旧硬件向导”(hdwwiz.exe)成功安装。从 的输出devcon hwids *可以看出,该设备如下所示。

ROOT\UNKNOWN\0000
    Name: RAMDrive [ QSoft ] Enterprise (x64)
    Hardware IDs:
        ramdriv

但是,我需要通过 Ansible 完成安装,因此hdwwiz.exe无法使用。它必须通过命令行完成,无需交互。

我尝试了几种方法,但都没有奏效。


方法一:DevCon.exe(Windows 设备控制台)

C:\Ramdisk64_inst>devcon.exe install RAMDriv.inf ramdriv

Device node created. Install is complete when drivers are installed...
Updating drivers for ramdriv from C:\Ramdisk64_inst\RAMDriv.inf.
devcon.exe failed.

C:\Ramdisk64_inst>devcon.exe install RAMDriv.inf ROOT\UNKNOWN\0000

Device node created. Install is complete when drivers are installed...
Updating drivers for ROOT\UNKNOWN\0000 from C:\Ramdisk64_inst\RAMDriv.inf.
devcon.exe failed.

这是来自的日志C:\Windows\INF\setupapi.dev.log

>>>  [Device Install (UpdateDriverForPlugAndPlayDevices) - ramdriv]
>>>  Section start 2018/12/20 07:10:35.670
      cmd: C:\Ramdisk64_inst\devcon.exe  install C:\Ramdisk64_inst\RAMDriv.inf ramdriv
     ndv: INF path: C:\Ramdisk64_inst\RAMDriv.inf
     ndv: Install flags: 0x00000001
!    ndv: Unable to find any matching devices.
<<<  Section end 2018/12/20 07:10:35.717
<<<  [Exit status: FAILURE(0xe000020b)]


>>>  [Device Install (UpdateDriverForPlugAndPlayDevices) - ROOT\UNKNOWN\0000]
>>>  Section start 2018/12/20 07:11:50.687
      cmd: devcon.exe  install RAMDriv.inf ROOT\UNKNOWN\0000
     ndv: INF path: C:\Ramdisk64_inst\RAMDriv.inf
     ndv: Install flags: 0x00000001
!    ndv: Unable to find any matching devices.
<<<  Section end 2018/12/20 07:11:50.734
<<<  [Exit status: FAILURE(0xe000020b)]

方法 2:DPInst.exe(驱动程序包安装程序)

C:\Ramdisk64_inst>dpinst.exe /PATH C:\Ramdisk64_inst /Q /C /LM

INFO:   Option set: dumping log info to console.
INFO:   Current working directory: 'C:\Ramdisk64_inst'
INFO:   Running on path 'C:\Ramdisk64_inst'
INFO:   No valid 'dpinst.xml' file provided.
INFO:   Install option set: Running in quiet mode. Suppressing Wizard and OS popups.
INFO:   Install option set: legacy mode on.
INFO:   Found driver package: 'C:\Ramdisk64_inst\RAMDriv.inf'.
INFO:   Preinstalling 'c:\ramdisk64_inst\ramdriv.inf' ...
INFO:   ENTER:  DriverPackagePreinstallW
INFO:   Driver package is already preinstalled 'c:\ramdisk64_inst\ramdriv.inf'.
SUCCESS:c:\ramdisk64_inst\ramdriv.inf is preinstalled.
INFO:   RETURN: DriverPackagePreinstallW  (0xB7)
INFO:   ENTER:  DriverPackageGetPathW
INFO:   RETURN: DriverPackageGetPathW  (0x0)
INFO:   ENTER:  DriverPackageInstallW
WARNING:DRIVER_PACKAGE_LEGACY_MODE flag set but not supported on Plug and Play driver on VISTA. Flag will be ignored.
INFO:   Installing INF file 'c:\ramdisk64_inst\ramdriv.inf' (Plug and Play).
INFO:   Looking for Model Section [DiskDevice.NTamd64]...
INFO:   No matching devices found in INF "C:\Windows\System32\DriverStore\FileRepository\ramdriv.inf_amd64_fcc99ac0622d865b\ramdriv.inf" on the Machine.
INFO:   No drivers installed. No devices found that match driver(s) contained in 'C:\Windows\System32\DriverStore\FileRepository\ramdriv.inf_amd64_fcc99ac0622d865b\ramdriv.inf'.
INFO:   RETURN: DriverPackageInstallW  (0xE000020B)
INFO:   No matching device was found for 'c:\ramdisk64_inst\ramdriv.inf'. Driver will be installed when plugged in.
INFO:   Returning with code 0x100

方法 3:rundll32 调用 SetupAPI

C:\Ramdisk64_inst>rundll32.exe setupapi.dll,InstallHinfSection DiskInstall 128 C:\Ramdisk64_inst\RAMDriv.inf

它结束没有任何错误,但没有安装驱动程序。


方法 4:PnPUtil

C:\Ramdisk64_inst>pnputil.exe /add-driver C:\Ramdisk64_inst\RAMDriv.inf /install /subdirs /restart

Microsoft PnP Utility

Adding driver package:  RAMDriv.inf
Driver package added successfully.
Published Name:         oem7.inf
Driver package installed on matching devices.

Total driver packages:  1
Added driver packages:  1

它成功了,但实际上驱动程序没有安装。


它们都不起作用。DpInst.exe 说No matching devices found in INF,DevCon.exe 说Unable to find any matching devices。似乎是同一个原因。

但是驱动可以hdwwiz.exe手动安装,有谁知道里面的秘密是什么hdwwiz.exe

4

1 回答 1

3

不能使用 pnputil 安装旧版驱动程序,必须使用 LaunchINFSectionEx-Call

我测试了以下内容,它适用于从 Windows 2000 到 Windows 10、2012R2、2016、2019 的多个驱动程序。

rundll32.exe advpack.dll,LaunchINFSectionEx ykmd.inf,Yubico64_Install.NT,,4,N

注意使用正确的部分

当没有 [DefaultInstall]-Section 时,必须使用 inf-File 的正确部分。这在大多数答案中都缺乏。在您的驱动程序 inf 文件中查找它并使用正确的部分(在我的示例中为“Yubico64_Install.NT”)。使用错误的部分不会提示错误。在我的示例中,我使用安静模式、无 UI (4) 和永不重启 (N) 来通过 GPO 自动安装驱动程序。所有选项都在此处详细记录:

https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768006(v%3Dvs.85)

于 2019-07-02T08:59:04.437 回答