我正在尝试编写一个在 Windows 7 上安装USB/以太网适配器的 VBS 脚本。
我有这个设备的 .INF 文件。
我第一次尝试:
Dim WshShell, res
Set WshShell = WScript.CreateObject("WScript.Shell")
res = WshShell.Run(WshShell.ExpandEnvironmentStrings( "%SystemRoot%" ) & "\System32\InfDefaultInstall.exe "" C:\Users\Me\Driver.inf """, 1, True)
res
等于 2。
然后我搜索了另一种方法,我发现:
Dim WshShell, res
Set WshShell = WScript.CreateObject("WScript.Shell")
res = WshShell.Run(WshShell.ExpandEnvironmentStrings( "%SystemRoot%" ) & "\System32\rundll32.exe SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 ""Driver.inf""", 1, True)
res
等于 0 但我有一个错误弹出窗口Installation failed
。
我的代码有什么问题?作为记录,该脚本以管理权限启动。
编辑
我试图直接在提示符下执行第一个命令并得到:The inf file you selected does not support this method of installation.
。
提示中的第二个命令没有任何反应。
这很奇怪,因为我可以在启动设备管理器并选择 inf 文件时“手动”安装驱动程序(带有警告:)Windows can't verify the publisher of this driver software.
:
安装驱动程序后,类安装程序属性显示NetCfgx.dll,NetClassInstaller
. 可以用吗?
我也尝试使用 devcon,但没有成功(程序返回 devcon.exe 失败)。