UltimaSerial How to pre-install USB drivers in Windows

Data logger


Windaq add-ons
Windaq Add-ons




Ultimaserial XChart




Ultimaserial Classroom


Any USB devices need its driver(s) to run under Window

The traditional way to do it was:

  1. Plug in the USB device
  2. Windows detects it and ask for a driver, like this 

  3. You feed a CD containing the driver(s) and follow the instruction to finish the installation. If your driver is not signed by Microsoft, you will run into a warning like this:

  4. When you move the device to a different USB port, you may have to go through step 2) and 3) again

With the latest Windows, you can pre-install the USB driver(s) so that Windows will not ask you for drivers when you plug in the device

To do so, you can write a small program to call SetupCopyOEMInf to let Windows know that you have supply the drivers for the USB device ahead of time. For more info regarding SetupCopyOEMInf, you can read it on http://msdn.microsoft.com/en-us/library/aa376990%28VS.85%29.aspx.

If you have VB6, here is the codes for the little utility:

Private Declare Function SetupCopyOEMInf Lib "setupapi.dll" Alias "SetupCopyOEMInfA" _
(ByVal SourceInfFileName As String, ByVal OEMSourceMediaLocation As String, _
ByVal OEMSourceMediaType As Long, ByVal CopyStyle As Long, ByVal DestinationInfFileName As String, _
ByVal DestinationInfFileNameSize As Long, ByRef RequiredSize As Long, _
ByVal DestinationInfFileNameComponent As String) _
As Long

Private Sub Form_Load()
On Error Resume Next
Dim param() As String
Dim ret2 As String * 255
Dim ret3 As String * 255
Dim ret As Long

If Command = "" Then End

param = Split(Command, "@@")

ret = SetupCopyOEMInf(param(0), param(1), 1, &H4, ret2, 255, 255, ret3)

If ret = 0 And UBound(param) = 2 Then
MsgBox "Sorry, but we failed in pre-installing USB drivers on this PC"
End If
End Sub

If you don't have VB6 around, here is the .exe form of this utility

To use this utility

  1. You need to pay to have your USB drivers signed by Microsoft. Otherwise pre-installing USB drivers will generate more Windows warnings than the traditional approach
  2. Once your drivers, including .inf and .sys files are signed. You can use any installation program to copy them, along with necessary .cat, .sys and .dlls to a target directory. 
  3. From the installation script, spawn the utility created above, with the following parameters <path of inf>@@<path of directory>, where @@ is the separator, e.g. c:\ultimaserial\usbdrivers\ftdiport.inf@@c:\ultimaserial\usbdrivers
  4. Repeat 3 for all necessary inf files. 
  5. Once the all drivers are pre-installed, your USB device can pick up them automatically when it is plugged into your PC.

For Vista users

Unfortunately, due to the missing manifest in VB6 apps, you may see a nagging window complaining the program might not have installed correctly. To address this problem, you may want to write this little program using Visual C++ 2008 Expression. 

  1. Create a Win32 console application
  2. Use the following codes

    #include "stdafx.h"

    int main(int argc, char *argv[])

    size_t convertedChars1 = 0;
    size_t convertedChars2 = 0;

    if (argc==3){
          size_t origsize1 = strlen(argv[1]) + 1;
          mbstowcs_s(&convertedChars1, wcstring1, origsize1, argv[1], _TRUNCATE);
          size_t origsize2 = strlen(argv[2]) + 1;
          mbstowcs_s(&convertedChars2, wcstring2, origsize2, argv[2], _TRUNCATE);
          ret=SetupCopyOEMInf(wcstring1, wcstring2, 1, 4, ret2,255, NULL,NULL);

          if (ret==0) printf("Failed to preinstall (%d)", GetLastError());
    printf("Wrong format");


    #include "stdafx.h"

    int main(int argc, wchar_t  argv[])

          if (SetupCopyOEMInf(argv[1], argv[2], 1, 4, ret2,255, NULL,NULL)==0) printf("Failed to preinstall (%d)", GetLastError());
    printf("Wrong format");



  3. Call this utility with the parameters <path of inf>  <path of directory>, e.g. c:\ultimaserial\usbdrivers\ftdiport.inf  c:\ultimaserial\usbdrivers
  4. Or, you can also try the compiled version of this utility



Last update: 03/12/13

Copyright: 2000-2005  www.UltimaSerial.com