Install inf driver using VBScript on Windows 7

I am trying to write a VBS script that installs a USB / Ethernet adapter in Windows 7.

I have a .INF file for this device.

First I tried:

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 equals 2.

Then I searched for another way to do this and 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)

resis 0, but I have an error popup Installation failed.

What happened to my code? For recording, a script is run with administrator rights.

EDIT

I tried to execute the first command directly in the invitation and received: The inf file you selected does not support this method of installation..

Nothing happens on the command line.

This is very strange, because I can install the driver “manually” when starting the device manager and select the inf file (with a warning:) Windows can't verify the publisher of this driver software.:

Windows security: Windows can't verify the publisher of this driver software

, NetCfgx.dll,NetClassInstaller. ?

devcon ( devcon.exe ).

+3
3

:

1) "Windows 7", , ? W7 "PNPUTIL". :

PNPUTIL -a "X:\Path to Driver File\Driver.inf"

INF CAT/SYS/INF ( DLL, EXE ..) "DriverStore"... . Windows , plug-and-play instalaltion.

2) , "DPInst.exe" ( "DPInst64.exe" 64- ). Windows PDK ( Microsoft) INF , , . "", "CatRoot" "INF", ... DLL "System32" ..... 99% ( ) . , , .

(1) , . 2 ISN Canon USB .., , .

+5

ASCII InstallHinfSection:

res = WshShell.Run("%Comspec% /C %SystemRoot%\System32\rundll32.exe SETUPAPI.DLL,InstallHinfSectionA DefaultInstall 132 ""Driver.inf""", 1, True)

, (, script, unicode/ASCII).

EN-US, .

+1

Try the following:

res = WshShell.Run("%Comspec% /C %SystemRoot%\System32\rundll32.exe SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 ""Driver.inf""", 1, True)
0
source

All Articles