在没有管理器提示的情况下安装 USB 设备

发布于 2024-08-31 14:58:26 字数 146 浏览 5 评论 0原文

我们有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

莫言歌 2024-09-07 14:58:26

您添加了“安装程序”标签,因此我假设您正在谈论某种安装包,例如 Windows Installer、InstallShield InstallScript 等。

如果是这种情况,您可能应该使用 Microsoft 的 DIFx 框架

DIFx 让您更轻松地创建
高品质的驱动程序包,
自定义驱动安装
包,允许安装
驱动程序包结合
应用软件,并使用
标准 Windows API 和安装
工具。 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.

DIFx makes it easier for you to create
high-quality driver packages,
customize the installation of driver
packages, allow the installation of
driver packages in combination with
application software, and use the
standard Windows APIs and installation
tools. DIFx also makes it easier for
end users to diagnose device and
driver problems. End users can be
confident that, if necessary, drivers
can be uninstalled or rolled back.

I've used DIFx from both Windows Installer-based installs and InstallScript installs. Very user-friendly, easy to debug, and effective.

爱给你人给你 2024-09-07 14:58:26

我的同事提出了一个非常有效的答案。看来,除非您的硬件/驱动程序组合经过 WHQL 签名,否则“添加新硬件向导”将始终出现在 Win XP 中。但是,通过以下方法,可以让向导中的“搜索”按钮自动找到您的驱动程序。在 Windows 7 中,没有任何提示,设备安装得很好。不过,您需要注意 64 位计算机,因为它们有更严格的签名执行。

这是整个文档的相关摘录:

使用DIFxAPi合并模块。 (阅读一篇好的Windows 中的驱动程序介绍、INF 文件的使用和 DIFxAPP。)DIFxAPI 合并模块包含在 WDK 的“WDDK//redist\DIFx\DIFxApp\MergeModule\”目录中。合并模块可以包含在 MSI 包中,并且可以设置为安装多个设备驱动程序。以下是使用 DIFxAPP 合并模块创建 MSI 的步骤:

  1. 在安装文件夹中,在应用程序文件夹中为驱动程序包创建一个单独的目录,并将驱动程序文件添加到该文件夹​​中。
  2. 将 DIFxApp.msm 添加到安装项目中。
  3. 构建设置
  4. 使用 Orca 编辑 MSI 数据库表并将 INF 组件添加到 DIFxAPP 合并模块表中。

    1. Orca 安装包含在 Windows SDK 的“C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin”目录中。 (Windows SDK 可以是 从 Microsoft 下载)
    2. 运行Orca并选择需要修改的MSI包。
      • 阅读第 5 部分了解自动化。
    3. 在“文件”表中,找到您要安装的驱动程序包的 INF 文件并复制组件值。
    4. 在 MsiDriverPackages 表中创建一个新行。将组件值添加到组件字段中。可以使用以下标志(尽管有些标志会被 Windows 7 忽略) ):

      • 0 - 未设置(默认)
      • 1 – 强制安装驱动程序,即使当前安装的驱动程序是
        比正在安装的驱动程序更匹配
      • 2 – 禁止消息框告诉用户在驱动程序之后插入设备
        已安装。
      • 4 – 禁止在驱动程序的“添加/删除程序”中添加条目。
        卸载主应用程序时,驱动程序也会被卸载。
      • 8 – 安装未签名的驱动程序包
      • 16 – 在卸载过程中删除驱动程序二进制文件。
    5. 保存 MSI。为了使该过程自动化,可以将 MSI 数据库的编辑记录到转换中,然后可以在构建后过程中应用该转换。
      1. 在 Orca 中打开 MSI。
      2. 选择变换 -> 新变换
      3. 按照上述说明完成第 3 步和第 4 步。
      4. 选择“变换”->“生成变换”并保存变换。
      5. 将以下行添加到安装项目的后期构建中
        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:

  1. In the setup folder, create a separate directory in the Application Folder for the driver package and add the driver files to the folder.
  2. Add the DIFxApp.msm to the setup project.
  3. Build the setup
  4. Use Orca to edit the MSI database table and add the INF component to the DIFxAPP merge modules table.

    1. The Orca installation is included in the Windows SDK in the ‘C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin’ directory. (The Windows SDK can be downloaded from Microsoft)
    2. Run Orca and select the MSI package that needs to be modified.
      • Read part 5 for automation.
    3. In the ‘File’ table, locate the INF file of the driver package you would like to install and copy the Component value.
    4. 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):

      • 0 - Not set (default)
      • 1 – Force installation of driver, even if it the currently installed drivers is
        a better match than the driver being installed
      • 2 – Suppress message box telling user to plug in devices after the driver
        has been installed.
      • 4 – Suppress adding an entry in Add/Remove Programs for driver.
        Driver will be uninstalled when main application is uninstalled.
      • 8 – Install unsigned driver packages
      • 16 – Remove driver binaries during uninstall.
    5. Save the MSI. In order to automate the process, the editing of the MSI database can be recorded to a Transform and then the Transform can be applied in a post build process.
      1. Open the MSI in Orca.
      2. Select Transform->New Transform
      3. Complete steps 3 and 4 in the above directions.
      4. Select Tranform->Generate transform and save the transform.
      5. Add the following line to the post build of the Setup Project
        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's Validate 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文