title: Install inf driver with VBScript on Windows 7
body: <p>I am trying to write a VBS script that install an <a href="http://store.apple.com/fr/product/MC704ZM/A/adaptateur-usb-ethernet-apple" rel="nofollow noreferrer">USB/Ethernet adapter</a> on Windows 7.</p>
  
  <p>I've got a .INF file for this device.</p>
  
  <p>I first tried:</p>
  
  <pre><code>Dim WshShell, res
  Set WshShell = WScript.CreateObject("WScript.Shell")
  res = WshShell.Run(WshShell.ExpandEnvironmentStrings( "%SystemRoot%" ) &amp; "\System32\InfDefaultInstall.exe "" C:\Users\Me\Driver.inf """, 1, True)
  </code></pre>
  
  <p><code>res</code> equaled 2.</p>
  
  <p>Then I searched another way to do that and <a href="http://msdn.microsoft.com/en-us/library/Aa376957" rel="nofollow noreferrer">I found</a>:</p>
  
  <pre><code>Dim WshShell, res
  Set WshShell = WScript.CreateObject("WScript.Shell")
  res = WshShell.Run(WshShell.ExpandEnvironmentStrings( "%SystemRoot%" ) &amp; "\System32\rundll32.exe SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 ""Driver.inf""", 1, True)
  </code></pre>
  
  <p><code>res</code> equals 0 but I've got an error popup <code>Installation failed</code>.</p>
  
  <p>What's wrong with my code? For the record, the script is launched with administration rights.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've tried to execute the first command directly in prompt and got: <code>The inf file you selected does not support this method of installation.</code>.</p>
  
  <p>Nothing happens with second command in prompt.</p>
  
  <p>This is very weird because I can install the driver "manually" when I launch the device manager and select the inf file (with a warning: <code>Windows can't verify the publisher of this driver software.</code>):</p>
  
  <p><img src="https://i.stack.imgur.com/4lf4v.jpg" alt="Windows security: Windows can&#39;t verify the publisher of this driver software"></p>
  
  <p>Once the driver is installed, the class installer property shows <code>NetCfgx.dll,NetClassInstaller</code>. Could it be used?</p>
  
  <p>I also tried with devcon with no success (program returns devcon.exe failed).</p>