In this blog post we will show following:
- How to find drivers
- What you will need to install drivers:
- Driver files
- DPInst.exe to install drivers (It usually can be found in Windows ADK or next to driver files)
- Certificates – In cases where a window is shown with the option to always trust the publisher you will need to add a certificate. The easiest way to find them is using regedit, but there are other options too.
- Path to Trusted Publisher certificates: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\TrustedPublisher\Certificates
- How to create Custom Actions for Installing Drivers using Master Packager
- How to create Template for future use
How to find DPInst.exe and drivers
To locate DPInst.exe:
- Open Process Monitor. Stop the capture and clear data.
- Run installation
- When DPInst.exe install windows appears, start the capturing process and when it finishes stop the process
- Add a filter – Set the Category to write. Add it and click apply
![Adding Filter in Process Monitor](https://www.masterpackager.com/uploads/file_archive/drivers_process_monitor_category.png)
- Search for a process with a name like DPInst*.exe, right click and select “Jump to”
![Locating dpinst.exe location in Process Monitor](https://www.masterpackager.com/uploads/file_archive/drivers_process_monitor_jump_to.png)
Note that the name of the executable can be slightly different. E.g.
DPINST.EXE, dpinst.x64.exe, dpinst-amd64.exe, dpinst-x86.exe,
DPInst32.exe etc.
Copy DPInst.exe to a new folder.
To locate driver files and registries:
- On clean VM open Master Repackager
- Create first snapshot
![Creating first snapshot in Master Repackager](https://www.masterpackager.com/uploads/file_archive/drivers_mr_first_snapshot.png)
- Run DPInst.exe
- After installation create second snapshot
![Saving system changes in Master Repackager](https://www.masterpackager.com/uploads/file_archive/drivers_mr_second_snap.png)
![Cleanup screen in Master Repackager](https://www.masterpackager.com/uploads/file_archive/drivers_mr_manage_files.png)
- In the files section under DriverStore locate driver files and copy them to the same folder where you copied DPInst.exe
![Locating driver files in Master Repackager](https://www.masterpackager.com/uploads/file_archive/drivers_mr_files.png)
- Locate Trusted Publisher certificates in the registries section
![Locating Trusted Publisher certificate registries in Master Repackager](https://www.masterpackager.com/uploads/file_archive/drivers_mr_registries.png)
- Open them in RegEdit
![Exporting Trusted Publisher certificate registries from Registry Editor](https://www.masterpackager.com/uploads/file_archive/drivers_regedit_export.png)
- Export the registries
Add drivers to MSI
- Open MSI with Master Packager
![Master Packager Home screen](https://www.masterpackager.com/uploads/file_archive/drivers_mp_home.png)
- In General Information add application name, version, vendor, ect.
- Go to the Files section. Create a new folder under [ProgramFilesFolder]\vendors_folder and place the drivers in it
![Adding files to MST in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_create_new_folder.png)
- Drag and drop located files and DPInst.exe exe into the folder and build a Cab file
![Creating CAB file in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_build_cab.png)
Add Trusted Publishers certificates
In Advanced Editor locate Registries section – drag and drop previously exported registries.
![Adding registries in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_add_registries.png)
Create Custom Actions
Go to Custom Actions.
![Adding Custom Actions in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_ca.png)
Installation Custom Action:
- Create a new Custom action called CA_Install_Drivers.
- Choose type Exe in File table
- As Execution Options select Deferred System
- Return Processing – Synchronous, ignore exit code – this will indicate that at installation process it would ignore exit code
- Scheduling Options set for Always
- Select DPInst.exe file
- In command line section add this line: /Q /F /LM /SA
![Creating Custom Action for driver installation in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_ca_install_drivers.png)
Uninstall Custom Action:
- Create a new Custom Action called CA_Uninstall_Driver
- Choose type Exe in File table
- As Execution Options select Deferred System
- Return Processing – Synchronous, ignore exit code
- Scheduling Options set for Always
- Select DPInst.exe.exe file
- In the command line section add this line: /u [#driverkey.inf] /d - replace file key for each driver file that you need to uninstall later. File keys can be found under File table. The file key is the first column of the file table called File.
![Creating Custom Action for driver uninstallation in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_ca_uninstall_drivers.png)
Pro tip!
To create Uninstall Custom Actions faster for each driver, open Table editor:
- Copy CA_Uninstall_Driver row and paste (Ctrl+Shift+C and Ctrl+Shift+C to copy whole row) new Custom actions as many as drivers we have
- For each driver that needs uninstall, change the command line’s driver key
![Custom Action table in Table editor view in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_ca_tableeditor.png)
- To find driver file keys go to File table and click on sequence in descending order to see last added files
![enter image description here](https://www.masterpackager.com/uploads/file_archive/drivers_file_keys.png)
Add created Custom Actions in InstallExecuteSequence
In advanced editor locate InstallExecuteSequence.
![Setting Install Execute Sequence in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_instexeseq.png)
Add CA_Install_Drivers:
- Select Action Type - Custom Actions
- Select Action Name – CA_Install_Drivers
- Add Condition – During Installation
- Set Sequence number – 6500. It must be somewhere between WriteRegistries and InstallFinalize actions
- Add Custom Action to the Install Execute Sequence list.
![Setting Install Execute Sequence for Driver installation Custom Action in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_instexeseq_ca_install.png)
Add each CA_Uninstall_Driver:
- Select Action Type - Custom Actions
- Select Action Name – CA_Uninstall_Driver
- Add Condition – During Uninstallation
- Set Sequence number – 3450. It must be somewhere before RemoveFiles and InstallFinalize actions
- Add it to the Install Execute Sequence list
- Repeat it to for each uninstall custom action
![Setting Install Execute Sequence for Driver uninstallation Custom Actions in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_instexeseq_ca_uninstall.png)
How to Create a Template for Future Use in Master Packager
- Open MSI and go to the Custom Actions table
- Select CA_Install_Drivers and CA_Uninstall_Driver rows
- Right-click on one of the selected rows and press the “Add to Template” button
![Adding Custom Actions to Template in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_create_template.png)
- Create a new template name and press the arrow button in the left textbox
![Creating new template in Master Packager](https://www.masterpackager.com/uploads/file_archive/drivers_add_to_template.png)
Add pre-existing template to your Master Packager
To add a pre-existing template, locate the Master Packager folder in your User Profile’s %appdata% directory.
![Add pre-existing template to your Master Packager](https://www.masterpackager.com/uploads/file_archive/add_template.png)
You can find your templates in there.
Note! The Template folder will only appear after you create a template in Master Packager.
Summary
Manually installing drivers for each user is time-consuming and inefficient. To install drivers silently, you should use DPInst.exe, Custom Actions and you might need a certificate for some drivers. Using templates in Master Packager allows you to speed up the process of adding custom actions to multiple MSI packages and reduce errors while creating them.
Template for Custom Action to Install Drivers