|
操作系统: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的秘密是什么吗?
旧版驱动程序无法与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 ... tform-apis/aa768006(v%3Dvs.85) |
|