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
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
Attachments

