Pnpunattend
Pnpunattend.exe is more reliable and faster than pnputil.
Registry Key Creation
Specify the path where the registry keys are located
$CheminDrivers = "C:\Drivers"
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\UnattendSettings\PnPUnattend\DriverPaths" -Name 1 -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\UnattendSettings\PnPUnattend\DriverPaths" -Name Path -Value $CheminDrivers -Force
Pnpunattend in Windows 10:
PnPnpunattend is native to Windows 10, so no installation is required.
Driver Audit:
If you only want to view the drivers to be installed without actually installing them, use the argument /s
pnpunattend.exe auditsystem /s /l
Driver Installation:
pnpunattend.exe auditsystem /l
Pnputil
Dpinst is no longer supported with Windows 10. The official tool is pnputil. Here are some command examples for pnputil.
c:\windows\system32\pnputil.exe /add-driver c:\drivers\*.inf /subdirs /install
pnputil /add-driver x:\driver.inf <- Ajouter le package de pilotes
pnputil /add-driver c:\oem\*.inf <- Ajouter plusieurs packages de pilotes
pnputil /add-driver device.inf /install <- Ajouter et installer le package de pilotes
pnputil /enum-drivers <- Énumérer les packages de pilotes OEM
pnputil /delete-driver oem0.inf <- Supprimer le package de pilotes
pnputil /delete-driver oem1.inf /force <- Forcer la suppression du package de pilotes
pnputil /export-driver oem6.inf . <- Exporter le package de pilotes
pnputil /export-driver * c:\backup <- Exporter tous les packages de pilotes
Dpinst
DPinst allows for the installation of drivers via command line (before Windows 10).
Dpinst is available with Microsoft’s “Windows Drivers Kit” and can also be found in certain drivers.
If you are creating master images under Windows 8.1, some of the drivers do not work in PnP mode (due to drivers not certified for Windows 8.1). This tool will allow you to force the installation of these drivers.
To install a driver
dpinst.exe /path "c:\drivers\Win8_1" /q /se
Note: The tool is not recursive (subfolders are not taken into account)
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("Wscript.Shell")
Const S_DP = "c:\pnpdrivers"
CopyInf(S_DP)
Sub CopyInf(dossier)
Set fs=fso.GetFolder(dossier)
'traitement des fichiers
Trouve = 0
Set collfiles = fs.Files
For Each File In collfiles
If Right(UCase(file.name),3) = "INF" And UCase(file.name) <> "AUTORUN.INF" Then
Trouve = 1
End If
Next 'File
If Trouve = 1 Then
wscript.Echo dossier
If FSO.FolderExists("C:\Windows\SysWOW64") Then
CodeRetour = Shell.run(chr(34) & GetPath & "x64\dpinst.exe" & chr(34) & " /path " & chr(34) & dossier & chr(34) & " /q /se",,True)
Else
CodeRetour = Shell.run(chr(34) & GetPath & "x86\dpinst.exe" & chr(34) & " /path " &chr(34) & dossier & chr(34) & " /q /se",,True)
End If
End If
'traitement des sous dossier
Set collfolders = fs.SubFolders
For each folder in collfolders
curfolder = dossier & "\" & folder.name
call CopyInf(curfolder)
Next
End Sub
Function GetPath()
Dim path
path = WScript.ScriptFullName
GetPath = Left(path, InStrRev(path, "\"))
End Function
The script allows scanning of subfolders and launching dpinst for each folder containing inf files.
Caution, you will need to change the driver path in the script.
Adding Drivers to a WIM
Ajouter des drivers en mode offline dans une WIM
- You can list available images in a WIM
dism /Get-ImageInfo /ImageFile:c:\fichier.wim
Disable your antivirus to prevent blocking the WIM during dismounting
- Mount Wim
The /Name option can be replaced by the /Index option
Dism /Mount-Image /ImageFile:c:\fichier.wim /Name:"Windows Offline Image" /MountDir:c:\mount
- Add Drivers
Dism /Image:c:\mount /Add-Driver /Driver:c:\Drivers /Recurse
- Saving the image
Dism /Unmount-Image/MountDir:c:\mount /Commit
Adding Drivers from WinPE
One solution is to use the DISM tool in the WinPE environment to force the installation of drivers in Windows. Here is the command line:
dism /image:c:\ /Add-driver /driver:\\Serveur\Chemin /recurse /forceunsigned
C:\ => Partition containing the Windows folder
Adding Unsigned Drivers with PnpUtil:
I finally found a simple solution to force unsigned drivers with pnputil.
- In the drivers, it’s the CAB file that interests us. When you right-click on this file
- In the ‘Digital Signature’ tab, click on ‘Details’.
- Then, in the new window under the ‘General’ tab, click on ‘View Certificate’.
- In the next window, under the ‘Details’ tab, click on ‘Copy to File’.
- Save the certificate in a .cer file.
The command is then quite straightforward.”
Certutil -addstore TrustedPublisher signature.cer
c:\windows\system32\pnputil.exe /add-driver "%~dp0TH230\*.inf" /subdirs /install
0 Comments