【发布时间】:2014-03-10 13:17:56
【问题描述】:
我正在尝试编写一个在 Windows 7 上安装 USB/Ethernet adapter 的 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。
然后我搜索了另一种方法并I found:
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 失败)。
【问题讨论】:
标签: windows installation driver inf