在没有管理器提示的情况下安装 USB 设备
我们有一个 USB 设备和驱动程序(.inf、libusb.dll、libusb.sys),可以使用 Windows 的设备安装向导(通过指向 .inf 文件)安装它。但是,我们需要在不使用向导的情况下安装驱动程序(被动地,因此用户不需要执行任何操作)。有谁知道如何实现这一点?
We have a usb device and the drivers (.inf, libusb.dll, libusb.sys) and can install it using Windows' Device Installation Wizard (by pointing to the .inf file). However, we need to install the drivers without using the wizard (passively, so the user doesn't need to do anything). Does anyone know how this can be achieved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您添加了“安装程序”标签,因此我假设您正在谈论某种安装包,例如 Windows Installer、InstallShield InstallScript 等。
如果是这种情况,您可能应该使用 Microsoft 的 DIFx 框架。
我在基于 Windows Installer 的安装和 InstallScript 安装中使用了 DIFx。非常用户友好,易于调试且有效。
You added the "installer" tag, so I'm assuming you're talking about some kind of installation package, like Windows Installer, InstallShield InstallScript, etc.
If that's the case, you should probably use Microsoft's DIFx framework.
I've used DIFx from both Windows Installer-based installs and InstallScript installs. Very user-friendly, easy to debug, and effective.
我的同事提出了一个非常有效的答案。看来,除非您的硬件/驱动程序组合经过 WHQL 签名,否则“添加新硬件向导”将始终出现在 Win XP 中。但是,通过以下方法,可以让向导中的“搜索”按钮自动找到您的驱动程序。在 Windows 7 中,没有任何提示,设备安装得很好。不过,您需要注意 64 位计算机,因为它们有更严格的签名执行。
这是整个文档的相关摘录:
使用DIFxAPi合并模块。 (阅读一篇好的Windows 中的驱动程序介绍、INF 文件的使用和 DIFxAPP。)DIFxAPI 合并模块包含在 WDK 的“WDDK//redist\DIFx\DIFxApp\MergeModule\”目录中。合并模块可以包含在 MSI 包中,并且可以设置为安装多个设备驱动程序。以下是使用 DIFxAPP 合并模块创建 MSI 的步骤:
使用 Orca 编辑 MSI 数据库表并将 INF 组件添加到 DIFxAPP 合并模块表中。
在 MsiDriverPackages 表中创建一个新行。将组件值添加到组件字段中。可以使用以下标志(尽管有些标志会被 Windows 7 忽略) ):
比正在安装的驱动程序更匹配
已安装。
卸载主应用程序时,驱动程序也会被卸载。
MsiDb.exe -t 变换.mst -d $(TargetDir)\DriverInstall.msi
注意:MsiDB.exe 随 Microsoft SDK 一起提供,位于
C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin
如果从 MSI 安装时出现错误(例如,我收到错误代码 2356,最终是由于
Flag
值无效) ,使用Orca的Validate
函数查看是否有错误。编辑:修复这些错误仍然没有消除错误。我记得读到 inf 文件应该位于它们自己的子目录中,但这也没有解决我的问题。My colleague came up with an answer that is working very well. It appears that, unless you hardware/driver combination is WHQL signed, the Add New Hardware Wizard will always appear in Win XP. However, with the following method it is possible to have the "Search" button in the wizard find your driver automatically. In Windows 7, there is no prompt and the device installs just fine. You'll need to watch out on 64-bit machines, though, as they have much stricter signing enforcement.
So here is the relevant excerpt from the whole document:
Use the DIFxAPi merge module. (Read a good introduction to drivers in Windows, the use of INF files, and DIFxAPP.) The DIFxAPI merge module is included in the WDK in the ‘WDDK//redist\DIFx\DIFxApp\MergeModule\’ directory. The merge module can be included in an MSI package and can be set to install multiple device drivers. Here are the steps to create an MSI with the DIFxAPP merge module:
Use Orca to edit the MSI database table and add the INF component to the DIFxAPP merge modules table.
Create a new row in the MsiDriverPackages table. Add the Component value into Component field. The following flags can be used (although some are ignored by Windows 7):
a better match than the driver being installed
has been installed.
Driver will be uninstalled when main application is uninstalled.
MsiDb.exe -t transform.mst -d $(TargetDir)\DriverInstall.msi
Note: MsiDB.exe comes with the Microsoft SDK and is located in
C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin
If you get an error installing from the MSI (e.g. I got error code 2356 which ended up being due to an invalid
Flag
value), use Orca'sValidate
function to see if there are any errors. EDIT: Fixing these errors still has not gotten rid of the error. I remember reading that inf files should be in their own sub-directory, but that didn't fix my problem either.