China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-28 05:06
中国DOS联盟论坛 » 其它操作系统综合讨论区 » Backing up drivers with pure script借助DevCon, compatible with Driver Genius (2008-01-17) View 81,551 Replies 72
Original Poster Posted 2007-11-06 13:30 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
At the request of members the post about safely deleting USB drives using pure scripts, I accidentally discovered the DevCon command and had an idea to write a script using this command to back up device drivers. This script can back up all device drivers, including hidden devices in Device Manager, and the backup items exceed those of the familiar Driver Genius.


Update Instructions:
  I can't say this script is more perfect than Driver Genius, but it does make up for the deficiencies of Driver Genius!
1、Supports backing up complete WHQL digital signatures (the Driver Genius 2005 Professional Edition I have doesn't support this), and I don't know about other updated versions because I don't want to worry about activating keys for higher versions :-)
2、Compatible with items that Driver Genius has already backed up, that is, running the script once will restore all items that Driver Genius has ever backed up, and the path is arbitrary, as long as it is searched out on the hard drive or USB drive and updated.
3、Supports the way of restoring driver by clicking the dialog box to select a single device with the mouse.
4、Supports the silent external installation and update of drivers, which is convenient for system integration and Ghost users to call.
5、Corrects possible copy errors, updates the screen display method when backing up, and prints out the device name containing the WHQL digital signature
6、Updated on 2008-01-17 to solve the problem of repeated backup of the same device and update the code stability





@echo off
title Backup Basic Device Drivers
::::::Related Discussions: http://www.cn-dos.net
::::::Online Forum:  http://groups.google.com/group/fastslz
::::::Personal Space: http://space.cech.com.cn/fastslz
if not %OS%==Windows_NT (cls&echo.&color 4E&echo This program must run on Windows NT or above operating system&ping/n 5 127.1>nul&exit)
devcon.exe>nul 2>nul
if %errorlevel%==9009 (cls&echo.&color 0E&echo This script requires the Microsoft DevCon.exe command-line utility&ping/n 5 127.1>nul&exit)
set log="Drivers\%~n0.log"
set Tempfile="%Temp:"=%.\fast.slz"
set count=0&set error=0&set whql=0
if not exist Drivers\nul MD Drivers
del "Drivers\*.log" 2>nul
cls&color 0b
echo.
echo Collecting device information, please wait...
for %%a in (PCI PCIIDE USB IDE DISPLAY USBPRINT) do (
for /f "tokens=1* delims=: " %%b in ('devcon find *%%a*^|find "\"') do echo "%%b"****"%%c">>"%Temp:"=%.\Devinfo.slz"
)
for /f "tokens=1* delims=****" %%b in ('type "%Temp:"=%.\Devinfo.slz"^|find /v ": "') do call :startcopy "@%%~b" "%%~c"
echo.
echo Have backed up %count% items of device drivers
>>%log% echo.
echo A total of %count% items of device drivers have been backed up>>%log%
if %error% gtr 0 (
echo.
if %error% equ 1 (
echo Encountered an error during copying
) else (
echo Encountered %error% errors during copying
)
echo Please check the log file %log%
)
endlocal
echo.
echo Press any key to exit. . .&pause>nul

:startcopy
color 0e
if "%~2"=="%forestall%" goto:eof
set "forestall=%~2"
setlocal enabledelayedexpansion
if "%~2"=="" goto:eof
del %Tempfile% 2>nul
set ID=%1
devcon driverfiles %1>%Tempfile% 2>nul
find ":\" %Tempfile%>nul
if errorlevel 1 goto:eof
if %count% equ 0 cls
set name="%~2"
>>%log% echo "%~2"
set ename=%name:&=_%
<nul set/p=Backing up--^> %ename:~0,54%
for %%k in (/ ; ,) do set name=!name:%%k=_!
rem set name=%name:(=
%
set name=%name:&=_and_%
set name=%name:"=%
for /f "tokens=1 delims=\" %%i in ('type %Tempfile%^|find "\"^|find /v ":"') do set class=%%i
for /f "tokens=1 delims=





























The above backup method is sufficient. If you want to back up all drivers, replace
for %%a in (PCI PCIIDE USB IDE DISPLAY) do (
for /f "tokens=1* delims=: " %%b in ('devcon find %%a\*^|find "\"') do call :startcopy "@%%b" "%%c"
)

with
for /f "tokens=1* delims=: " %%b in ('devcon findall *^|find "\"') do call :startcopy "@%%b" "%%c"

Related Information: Microsoft DevCon Command-Line Utility Can Replace Device Manager

The CMD code for restoring and updating items backed up by Driver Genius is in post 15

[ Last edited by fastslz on 2008-3-19 at 09:51 AM ]
Recent Ratings for This Post ( 6 in total) Click for details
RaterScoreTime
abcd +4 2007-11-06 14:21
lxmxn +8 2007-11-06 14:28
baomaboy +7 2007-11-06 20:39
everest79 +15 2007-11-07 00:25
vkill +4 2007-11-07 22:04
wangjf +4 2008-02-14 16:29
Attachments
备份驱动.rar (91.35 KiB, Credits to download 1 pts, Downloads: 312)
第一高手 第二高手

Floor 2 Posted 2007-11-06 20:24 ·  中国 香港 腾讯云
初级用户
★★
Credits 172
Posts 63
Joined 2007-11-03 10:37
18-year member
UID 101564
Gender Male
Status Offline
COOL, just found out about this great thing from Master vkill and immediately used it. The test results are as follows:

Backing up driver ---> "Intel(R) 82845 Processor to I/O Controller - 1A30"
Backing up driver ---> "Intel(R) 82845 Processor to AGP Controller - 1A31"
Backing up driver ---> "Intel(R) 82801BA LPC Interface Controller - 2440"
Backing up driver ---> "Intel(R) 82801BA/BAM USB Universal Host Controller - 2442"
Backing up driver ---> "Intel(R) 82801BA/BAM SMBus Controller - 2443"
Backing up driver ---> "Intel(R) 82801BA/BAM USB Universal Host Controller - 2444"
Backing up driver ---> "Intel(r) 82801BA/BAM AC'97 Audio Controller"
Backing up driver ---> "Intel(R) 82801BA Ultra ATA Storage Controller - 244B"
Backing up driver ---> "Intel(R) 82801 PCI Bridge - 244E"
Backing up driver ---> "USB Root Hub"
Backing up driver ---> "USB Root Hub"
Backing up driver ---> "Unknown Device"
Backing up driver ---> "USB USB\VID_8086&PID_1122\5&16DC22A8&0&2
: Generic USB Hub"
Backing up driver ---> "WDC WD400BB-00JHC0"

17 device drivers have been backed up

An error occurred during the copying process
Please check the log file "Drivers\1.log"

Press any key to continue...

It seems there is a bit of duplicate backup.
Floor 3 Posted 2007-11-06 20:27 ·  中国 香港 腾讯云
初级用户
★★
Credits 172
Posts 63
Joined 2007-11-03 10:37
18-year member
UID 101564
Gender Male
Status Offline
Looking forward to the work of restoring the driver!
Attachments
1.gif
Floor 4 Posted 2007-11-07 13:26 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Restoring drivers is not easy to handle. I've thought of several solutions, but now my mind is full of symbols, and I'm completely at a loss. The devcon install parameter isn't suitable for the known hardware, and devcon update must first obtain the hardware ID. The hardware ID has a certain pattern but is not easy to screen, and we also need to screen out those that don't need to be updated.
第一高手 第二高手

Floor 5 Posted 2007-11-07 13:52 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
This floor I'll just post some Devcon related parameters and other applications


Common types: PCI PCIIDE USB USBSTOR IDE PCIIDE DISPLAY
Devcon hwids * Get all hardware IDs
Devcon hwids Common types\* Get common type hardware IDs
Devcon find Common types\* Find common type hardware information
Devcon find gendisk Only find hard disk including mobile hard disk information
Devcon find gencdrom Only find CD-ROM information
Devcon update xxx.inf Hardware ID Update driver


Query: All PCI, AGP, PCI-X, PCIe hardware IDs and names in the world This site continuously updates information (if you are an OEM device then check it out)

@echo off
setlocal enabledelayedexpansion
echo Hard disk model Interface type Revision version
echo ======== ======== ========
for /f "tokens=1,2* delims=\" %%a in ('devcon.exe find gendisk^|find /v /i "USBSTOR\"^|find ":"') do call :fastslz "%%a" "%%b" "%%c"
echo.&pause
:fastslz
set "Fill space= "
set type=%~1%Fill space%
set revision=%~2
set revision=%revision:_= %
for %%i in (%revision%) do set revision=%%i
for /f "tokens=1* delims=:" %%a in ('echo %3') do set model="%%~b"
set model=%model:~0,30%
set model=%model:"=%%Fill space%
set model=%model:~1,30%
echo %model%%type:~0,12%%revision%
goto:eof


[ Last edited by fastslz on 2007-11-7 at 06:09 PM ]
第一高手 第二高手

Floor 6 Posted 2007-11-07 21:49 ·  中国 甘肃 定西 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
After running devcon hwids *, the following section is observed:


PCI\VEN_1002&DEV_4153&SUBSYS_41531FD3&REV_00\4&1AD7642&0&0058
Name: RADEON 9550
Hardware ID's:
PCI\VEN_1002&DEV_4153&SUBSYS_41531FD3&REV_00
PCI\VEN_1002&DEV_4153&SUBSYS_41531FD3
PCI\VEN_1002&DEV_4153&CC_030000
PCI\VEN_1002&DEV_4153&CC_0300
Compatible ID's:
PCI\VEN_1002&DEV_4153&REV_00
PCI\VEN_1002&DEV_4153
PCI\VEN_1002&CC_030000
PCI\VEN_1002&CC_0300
PCI\VEN_1002
PCI\CC_030000
PCI\CC_0300


Backing up the driver ---> "RADEON 9550 "
Press any key to continue. . .

Now, looking at the just-backed-up folder, there is an inf file.


C:\>cd "C:\Downloads\Drivers\PCI\RADEON 9550\"

C:\Downloads\Drivers\PCI\RADEON 9550>devcon update oem4.inf "PCI\VEN_1002&DEV_41
53&SUBSYS_41531FD3&REV_00"
Updating drivers for PCI\VEN_1002&DEV_4153&SUBSYS_41531FD3&REV_00 from C:\Downlo
ads\Drivers\PCI\RADEON 9550\oem4.inf.
Drivers updated successfully.



I think it should be no problem to update all four of the following:
Hardware ID's:
PCI\VEN_1002&DEV_4153&SUBSYS_41531FD3&REV_00
PCI\VEN_1002&DEV_4153&SUBSYS_41531FD3
PCI\VEN_1002&DEV_4153&CC_030000
PCI\VEN_1002&DEV_4153&CC_0300
Whoever tests it is fine.

[ Last edited by vkill on 2007-11-7 at 09:58 PM ]
Floor 7 Posted 2007-11-07 22:09 ·  中国 甘肃 定西 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
C:\>cd C:\Downloads\Drivers\USB\USB Root Hub

C:\Downloads\Drivers\USB\USB Root Hub>devcon update "C:\Downloads\Drivers\USB\US
B Root Hub\usbport.inf" "USB\ROOT_HUB&VID10DE&PID00E7&REV00A1"
Updating drivers for USB\ROOT_HUB&VID10DE&PID00E7&REV00A1 from C:\Downloads\Driv
ers\USB\USB Root Hub\usbport.inf.
Drivers updated successfully.

C:\Downloads\Drivers\USB\USB Root Hub>devcon update "C:\Downloads\Drivers\USB\US
B Root Hub\usbport.inf" "USB\ROOT_HUB&VID10DE&PID00E7"
Updating drivers for USB\ROOT_HUB&VID10DE&PID00E7 from C:\Downloads\Drivers\USB\
USB Root Hub\usbport.inf.
Drivers updated successfully.

C:\Downloads\Drivers\USB\USB Root Hub>devcon update "C:\Downloads\Drivers\USB\US
B Root Hub\usbport.inf" "USB\ROOT_HUB"
Updating drivers for USB\ROOT_HUB from C:\Downloads\Drivers\USB\USB Root Hub\usb
port.inf.
Drivers updated successfully.
Like this update of the USB Root Hub has no problems, everything is normal
Floor 8 Posted 2007-11-07 23:00 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
```
PCI\VEN_1002&DEV_4153&SUBSYS_41531FD3&REV_00
PCI\VEN_1002&DEV_4153&SUBSYS_41531FD3
PCI\VEN_1002&DEV_4153&CC_030000
PCI\VEN_1002&DEV_4153&CC_0300
Compatible ID's:
PCI\VEN_1002&DEV_4153&REV_00
PCI\VEN_1002&DEV_4153
PCI\VEN_1002&CC_030000
PCI\VEN_1002&CC_0300
PCI\VEN_1002
PCI\CC_030000
PCI\CC_0300
```
The above are all hardware IDs, some are fewer and some are more. devcon update oem4.inf can successfully update all 10 above. The most common one is PCI\VEN_1002, that is, filter out the first few digits before the first occurrence of &. This filtering is the most common. But sometimes it is not common on USB devices such as
"@USB\ROOT_HUB\4&1D255E7A&0"
"@USB\ROOT_HUB\4&84E02D0&0"
"@USB\ROOT_HUB\4&A6BADD5&0"


The hardware IDs have been generated during backup and saved in HardwareID.log
第一高手 第二高手

Floor 9 Posted 2007-11-08 13:04 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
The restore driver has been written. It's packed and downloadable on the first floor. sed.exe is needed. If you have any questions, post a reply.

Also, friends who have SATA, SATAII, SCSI, IEEE1394 devices, please let us know whether these devices are in the common types. Thanks



































[ Last edited by fastslz on 2007-11-8 at 05:10 PM ]
第一高手 第二高手

Floor 10 Posted 2007-11-08 13:56 ·  中国 浙江 杭州 阿里云
初级用户
★★
Credits 172
Posts 63
Joined 2007-11-03 10:37
18-year member
UID 101564
Gender Male
Status Offline
NVIDIA GeForce4 MX 440 (Microsoft Corporation)
D-Link DFE-530TX PCI Fast Ethernet Adapter (rev.C) #3
D-Link DFE-530TX PCI Fast Ethernet Adapter (rev.C) #2
Intel(R) 82845 Processor to I/O Controller - 1A30
Intel(R) 82845 Processor to AGP Controller - 1A31
Intel(R) 82801BA LPC Interface Controller - 2440
Intel(R) 82801BA/BAM USB Universal Host Controller - 2442
Intel(R) 82801BA/BAM SMBus Controller - 2443
Intel(R) 82801BA/BAM USB Universal Host Controller - 2444
Intel(r) 82801BA/BAM AC'97 Audio Controller
Intel(R) 82801BA Ultra ATA Storage Controller - 244B
Intel(R) 82801 PCI Bridge - 244E
USB Root Hub
USB Root Hub
Unknown Device
USB USB\VID_8086&PID_1122\5&16DC22A8&0&2 : Generi
SB Hub
File not found - input.inf
WDC WD400BB-00JHC0

Please select the device name to update, input continuously more than 5 bytes vaguely ↘








Don't know how to use
Floor 11 Posted 2007-11-08 14:03 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
I just found out too. This situation will occur with full backups. Oh, need to fix....
Fuzzy input means NVIDIA GeForce4 MX 440 (Microsoft Corporation), just input NVIDIA

[ Last edited by fastslz on 2007-11-8 at 02:04 PM ]
第一高手 第二高手

Floor 12 Posted 2007-11-08 14:25 ·  中国 浙江 杭州 阿里云
初级用户
★★
Credits 172
Posts 63
Joined 2007-11-03 10:37
18-year member
UID 101564
Gender Male
Status Offline
Not bad, not bad. It is suggested to add an auto parameter additionally. It can restore all drivers in the Drives directory in silent mode. (Even if there are individual errors, no prompt will be given) If this can also be realized, it is suggested to add a compression package function to "Backup Drivers.bat" and "Restore Drivers". Package all drivers into a file like mydrives.zip. For restoration, just unzip it first. Wow, in this way, it won't be long before those GHOST system - like installation discs for installing systems will have new updates. Haha. Why isn't such a good post highlighted?
Floor 13 Posted 2007-11-08 15:39 ·  中国 上海 联通
新手上路
Credits 4
Posts 2
Joined 2007-10-30 15:13
18-year member
UID 101187
Gender Male
Status Offline
Expert! I only use this tool to switch network cards! One network card is boardcom, and the other is 8139. Because one is internal and the other is external, so it's troublesome to do it manually!!

devcon disable *DEV_1677* >nul
devcon enable *DEV_8139* >nul
Floor 14 Posted 2007-11-08 17:56 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Originally posted by hello547rf44 at 2007-11-8 14:25:
Not bad, not bad. Suggest adding an additional auto parameter. It can restore all drivers in the Drives directory in silent mode. (Even if there are individual errors, no prompts are given) If this can also be achieved, then suggest "Backup drivers...

Restoring also requires driver optimization, this is just a temporary restore script. Compression is the simplest, directly call
start winrar.exe u -ep1 -m5 -r .\MyDrivers.rar .\*
As for ghost system, I'm not keen on it, but if the drivers and hardware IDs are collected enough, it can be completely done. I prefer to install drivers with external scripts when installing the system

Originally posted by sh2288 at 2007-11-8 15:39:
Expert!! I only use this tool to switch network cards!!
One network card is boardcom, and the other is 8139. Because one is internal and the other is external, so it's troublesome to do manually!!

devcon disable *DEV_1677* >nul
devcon enable *DEV_8139* >nul

Indeed, it's a good method. Situations like yours are very common, hehe, now there are new tricks...
第一高手 第二高手

Floor 15 Posted 2007-11-13 14:07 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
```code
@echo OFF
title Restore Update (Driver Genius) Backup Items
::::::Related Discussion: http://www.cn-dos.net
::::::Online Forum:  http://groups.google.com/group/fastslz
::::::Personal Space: http://space.cech.com.cn/fastslz
if not %OS%==Windows_NT (cls&echo.&color 4E&echo This program must run on Windows NT or above 2000 operating system&ping/n 5 127.1>nul&EXIT)
devcon.exe>nul 2>nul
if %errorlevel%==9009 (cls&echo.&color 0E&echo This script requires the support of Microsoft DevCon.exe command-line utility&ping/n 5 127.1>nul&EXIT)
set log="Drivers\%~n0.log"
set Tempfile="%Temp:"=%.\fast.slz"
set count=0
del "Drivers\*.log" 2>nul
del %Tempfile% 2>nul
cls&color 0b
echo.
echo Searching for (Driver Genius) backup item information throughout the disk, this may take a long time, please wait...
setlocal enabledelayedexpansion
for /f "delims=\" %%i in ('fsutil fsinfo drives^|find /v "a"') do (
set var=%%i
set drive=!var:~-2!
fsutil fsinfo drivetype !drive!\|find /v "-ROM">nul &dir /s /b /a-d !drive!\Driver.nfo>>%Tempfile% 2>nul
)
for /f "delims=*" %%i in ('type %Tempfile%^|find /i /v "RECYCLE"') do type "%%i"|find /i "InfFile">nul 2>nul
if %errorlevel%==1 cls&echo.&color 0e&echo No (Driver Genius) backup item information found on all local disks and removable disks&echo If the driver file is compressed, please extract the file to any location, then run this script&ping/n 10 127.1>nul&exit/b

:::::goto Driver_start
Wprompt "Prompt Information" "Press OK to start restoring the items backed up by Driver Genius, please contact me for the single recovery mode script " OkCancel 2 ?
if %errorlevel%==2 color 0e&echo User canceled the operation . . .&ping/n 3 127.1>nul&exit/b

:Driver_start
cls
for /f "delims=*" %%i in ('type %Tempfile%^|find /i /v "RECYCLE"') do (
for /f "tokens=1* delims==" %%a in ('type "%%~i"^|find /i "DriverName"') do (
for /f "tokens=1* delims==" %%e in ('type "%%~i"^|find /i "InfFile"') do (
for /f "tokens=1* delims==&" %%k in ('type "%%~i"^|find /i "HardwareID"') do (call :startdriver "%%b" "%%~dpi%%f" "%%l")
)
)
)
del %Tempfile% 2>nul
echo.
echo A total of %count% device drivers were updated
echo.
echo Press any key to exit. . .&pause>nul

:startdriver
set "ID=%~3"
set "typename=%~1"
if not defined typename goto:eof
set/p=Updating--^> "%typename:~0,47%"<nul
if not exist "%~2" echo No corresponding item, execute the next item . . .&ping/n 2 127.1>nul&goto:eof
rem If the update cannot be successful, try adding symbols to the next for statement delims=&
for /f "delims=" %%m in ('echo."%ID%"') do devcon updateNI "%~2" "%%~m">nul
if %errorlevel%==0 color 0e&echo ^<--Device driver has been updated&ping/n 1 127.1>nul&color 0b
if %errorlevel%==1 color 0e&echo ^<--Update prompt to restart&ping/n 1 127.1>nul&color 0b
if %errorlevel%==2 color 0e&echo ^<--Update failed!&echo The reason is that the hardware ID is not correctly judged, or the driver source is incorrect.&ping/n 1 127.1>nul
if %errorlevel%==3 color 0e&echo DevCon syntax error.&ping/n 1 127.1>nul
set /a "count=%count%+1"
del %Tempfile% 2>nul
endlocal&(set count=%count%)
goto:eof

[ Last edited by fastslz on 2008-1-17 at 10:26 PM ]
```
第一高手 第二高手

1 2 3 5 Next ›
Forum Jump: