[Windows] Batch backup and installation of drivers!Introducing an example of creating commands and batch files!

Windows

Hello!This time, I will show you how to back up the installed drivers in a batch and how to restore them!

The method of backing up the driver is often performed by a clean installation of the OS or repair of the driver.However, I don't think there is any specific information about how to do it.

I think the most common method is to save the driver installer, but installing each one is very time consuming and labor intensive.The method introduced this time is a comfortable method to back up / install all at once.

Bulk driver backup command

You can back up the drivers in a batch by using the following command.

mkdir C: \ Backup
dism / online / export-driver / destination:"C: \ Backup"

C: \ BackupThe part of is the save destination, so please rewrite it arbitrarily.
If there is no save destination folder, an error will occur, so it is better to create it first with mkdir.
This command allows you to save all third-party drivers.

* However, please note that the attached utility is not saved, so you may need to prepare a separate installer if necessary.

Example)
Display driver setting software
Printer ink level status information monitor
な ど

[Reference] Command line options for Microsoft DISM driver service (.inf)

https://msdn.microsoft.com/ja-jp/library/windows/hardware/dn898546(v=vs.85).aspx

Batch driver installation batch

Next is the batch installation method.
There are ways to install the driver, such as the Add-Driver option of the Dism command, rundll32, Devcon.exe, etc., but I personally found it easier to use pnputil, so I created the following batch and realized it. Did.
If you are interested in other methods, please check it out.I will summarize if there is an opportunity.

@ Echo off
cd / d% ~ dp0
Install the echo driver
pause

for / f %% a in ('dir / b /s*.inf') do (
      echo %% a installation
      pnputil / add-driver %% a / install
)
pause

Create a batch file with this content and save it in the backup folder of the driver you saved earlier.Then run the batch file with administrator privileges and the drivers will be installed sequentially.

Basically, I use pnputil's add-driver and install options. The inf file name of the driver is entered in the %% a part. Use the For command to read all the inf files in the folder and install with pnputil.

Some drivers may not be installed because the drivers installed by default are also backed up.Also, it seems to be a little rough operation, so it may be close to a method to prevent it from becoming unusable in case of emergency.

For the time being, in my environment, when I restored the backup before the clean installation by using this method for the OS of the clean installation, no unknown device remained on the device manager.

[Reference] Command syntax of Microsoft PnPUtil

https://docs.microsoft.com/ja-jp/windows-hardware/drivers/devtest/pnputil-command-syntax

Warnings

I've encountered it several times when installing this way, but for some reason it didn't recognize it properly once.

This installs the driver inf file itself, but I think it is up to the computer to detect the device and apply the driver.Therefore, you may need to take some time after installation, reboot, run the installation batch again, and so on.

As mentioned above, it doesn't behave like that, so there may be a better way.
If you find another way, I would like to introduce it again.

I hope it helps you.

Comment

Translate »
I copied the title and URL