【问题标题】:Inf file can't find usbser.sys in Windows 7 onlyInf 文件仅在 Windows 7 中找不到 usbser.sys
【发布时间】:2026-01-06 21:55:02
【问题描述】:

更新:感谢下面的答案,我设法让它在 Windows 7 上运行。我已经意识到 Windows 10 安装但使用 OEM USB 串行驱动程序覆盖了我的驱动程序。请看:Trouble installing custom inf in Windows 10 Professional. Windows overrides it with OEM driver

-

我试图制作一个 Inf 文件,该文件使用标准的 windows usb-serial 驱动程序安装 usb-serial 设备。此文件在 Windows 8.1 和 Windows 10 上成功安装驱动程序,但在 Windows 7 32 位和 Windows 7 64 位上失败。我试图从桌面右键单击安装驱动程序(默认安装)。第一次尝试时,我收到错误“您建议的 inf 文件不支持这种安装方法”。我将 defaultInstall 部分添加到 inf 文件中。在我这样做之后,错误消失了,但系统找不到 usbser.sys。 "需要 windows cd 上的文件 'usbser.sys'。"

为了从 Windows 7 成功安装,我需要向下面的 inf 文件添加什么?

当前 inf 文件:

;************************************************************
; Windows USB CDC ACM Setup File
; Copyright (c) 2000 Microsoft Corporation

; Version v1.1, updated 17 April 2013

[Version]
Signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%MFGNAME%
LayoutFile=layout.inf
CatalogFile=%MFGFILENAME%.cat
DriverVer=11/15/2007,5.1.2600.0

[Manufacturer]
%MFGNAME%=DeviceList, NTamd64

[DestinationDirs]
DefaultDestDir=12

;------------------------------------------------------------------------------
;  Windows 2000/XP/Vista-32bit Sections
;------------------------------------------------------------------------------

;DEFAULT SECTION ADDED
;---------------------------------------------
[DefaultInstall.nt]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.nt
AddReg=DriverInstall.nt.AddReg

[DefaultInstall.nt.Services]
AddService=usbser, 0x00000002, DriverService.nt
;---------------------------------------------

[DriverInstall.nt]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.nt
AddReg=DriverInstall.nt.AddReg

[DriverCopyFiles.nt]
usbser.sys,,,0x20

[DriverInstall.nt.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

[DriverInstall.nt.Services]
AddService=usbser, 0x00000002, DriverService.nt

[DriverService.nt]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys

;------------------------------------------------------------------------------
;  Vista-64bit Sections
;------------------------------------------------------------------------------

;DEFAULT SECTION ADDED
;---------------------------------
[DefaultInstall.NTamd64]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.NTamd64
AddReg=DriverInstall.NTamd64.AddReg

[DefaultInstall.NTamd64.Services]
AddService=usbser, 0x00000002, DriverService.NTamd64
;----------------------------------

[DriverInstall.NTamd64]
include=mdmcpq.inf
CopyFiles=DriverCopyFiles.NTamd64
AddReg=DriverInstall.NTamd64.AddReg

[DriverCopyFiles.NTamd64]
%DRIVERFILENAME%.sys,,,0x20

[DriverInstall.NTamd64.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

[DriverInstall.NTamd64.Services]
AddService=usbser, 0x00000002, DriverService.NTamd64

[DriverService.NTamd64]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\%DRIVERFILENAME%.sys


;------------------------------------------------------------------------------
;  Vendor and Product ID Definitions
;------------------------------------------------------------------------------
; When developing your USB device, the VID and PID used in the PC side
; application program and the firmware on the microcontroller must match.
; Modify the below line to use your VID and PID.  Use the format as shown below.
; Note: One INF file can be used for multiple devices with different VID and PIDs.
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
;------------------------------------------------------------------------------
[SourceDisksFiles]
[SourceDisksNames]
[DeviceList]
%linux.gserial%=DriverInstall, USB\VID_1FC9&PID_816A, USB\VID_1FC9&PID_816A&MI_00

[DeviceList.NTamd64]
%linux.gserial%=DriverInstall, USB\VID_1FC9&PID_816A, USB\VID_1FC9&PID_816A&MI_00

;------------------------------------------------------------------------------
;  String Definitions
;------------------------------------------------------------------------------
;Modify these strings to customize your device
;------------------------------------------------------------------------------
[Strings]
MFGFILENAME="c500"
DRIVERFILENAME ="usbser"
MFGNAME="Rinstrum Pty Ltd"
INSTDISK="Rinstrum USB Gadget Serial Driver Installer"
linux.gserial="Rinstrum USB Gadget Serial"
SERVICE="USB RS-232 Emulation Driver"

如果我随后在命令行上使用命令 RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 c500.inf,则会收到“安装失败”错误提示。

【问题讨论】:

    标签: windows usb driver cat inf


    【解决方案1】:

    我已经制作了许多在 Windows 7 上运行的基于 usbser.sys 的驱动程序。下面是一个示例:https://github.com/pololu/p-star-examples/blob/master/drivers/p-star-serial.inf

    我认为您不需要有“DriverCopyFiles.nt”部分和对它的引用。查看我在上面链接到的驱动程序,它显示了如何改为引用“FakeModemCopyFileSection”。

    另外,你的一个看起来很可疑的一件事是你选择通过“字符串”部分中的字符串来制作“usbser”。我真的不明白这一点,并且该字符串定义附近的空格被弄乱了。你可以在使用它的地方写上“usbser”。

    【讨论】:

    • 感谢您的回答。我注意到您直接在 CopyFiles 部分调用了您的 inf 文件。这不是坏习惯吗? “注意 CopyFiles 指令不应引用目录文件或 INF 文件本身;SetupAPI 会自动复制这些文件。” - msdn.microsoft.com/en-us/windows/hardware/drivers/ifs/…
    • 再看一遍,我没有引用我自己的 INF 文件的 CopyFiles 指令。
    • 很抱歉。遵循您的模板后,我似乎在 Win7 32 上取得了一些成功。现在尝试其他操作系统。
    • 这在 Windows 10 中不起作用。即使我在插入 USB 设备之前运行 inf 文件,它也只会使用通用 USB 串行驱动程序并显示为“USB 串行设备”,而不是我在 inf 文件中使用的正确驱动程序名称。知道 Windows 10 缺少什么吗?
    • 您在安装正确的驱动程序之前将设备插入 Windows 10,因此它与 Windows 10 (usbser.inf) 附带的通用驱动程序一起使用。您的设备完全可用,但如果您想在设备管理器中看到正确的名称,请右键单击它并选择卸载,然后拔下并重新插入。
    【解决方案2】:

    这除了大卫格雷森的回答。我使用他在https://github.com/pololu/p-star-examples/blob/master/drivers/p-star-serial.inf 的示例作为我的 inf 文件的基础。

    确保您在 .inf 文件中指定的任何标识信息与设备管理器中显示的硬件 ID 完全匹配。例如,我曾经在硬件 ID 中有一些 &MI_00 或 &MI_01 的东西,这使得 Windows 与设备不匹配。

    嗯,似乎不需要 &REV_0000。

    【讨论】:

      最近更新 更多