DEVCON 을 이용한 프린터 & 기타 드라이버 관리 등

반응형



프린터 드라이버 EXPORT SCRIPT.

출처 : http://www.robvanderwoude.com


@ECHO OFF

:: Check Windows version and command line argument(s)

REM IF NOT "%OS%"=="Windows_NT" GOTO Syntax

REM IF     "%~1"=="" GOTO Syntax

REM IF NOT "%~2"=="" GOTO Syntax


:: Localize variables and enable delayed variable expansion

SETLOCAL ENABLEDELAYEDEXPANSION


:: Check if DEVCON.EXE is available and if not, offer to download it

SET DevconAvailable=

SET Download=


DEVCON.EXE /? >NUL 2>&1

IF ERRORLEVEL 1 (

SET DevconAvailable=No

ECHO This batch file requires Microsoft's DEVCON untility.

SET /P Download=Do you want to download it now? [y/N] 

)


:: Start download if requested

IF /I "%Download%"=="Y" (

START "DevCon" "http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272"

ECHO.

ECHO Install the downloaded file and make sure DEVCON.EXE is in the PATH.

ECHO Then try again.

)


:: Abort if DEVCON.EXE is not available yet

IF "%DevconAvailable%"=="No" (

ENDLOCAL

GOTO:EOF

)


:: Check how many matching printers are found, if any

FOR /F %%A IN ('DEVCON Find ^=Printer "%~1*" 2^>NUL ^| FIND.EXE /C "\"') DO SET Matches=%%A

IF %Matches% EQU 0 (

CLS

ECHO.

ECHO ERROR: Specified printer not found

GOTO Syntax

)

IF %Matches% GTR 1 ECHO %Matches% matching printers found


:: Create a directory the driver files will be copied to

MD "%~1" >NUL 2>&1


:: Create a batch file "install_driver.bat" to (re)install the driver(s)

>  "%~1\install_driver.bat" ECHO :: Batch file generated by ExpPrnDr.bat (Export Printer Drivers),

>> "%~1\install_driver.bat" ECHO :: written by Rob van der Woude, http://www.robvanderwoude.com

>> "%~1\install_driver.bat" ECHO PUSHD "%%~dp0"


:: Create an empty readme.txt

TYPE NUL > "%~1\readme.txt"


:: Find and copy the driver files for the specified printer(s),

:: and append the install command(s) to "install_driver.bat"

FOR /F "tokens=1-5*" %%A IN ('DEVCON DriverFiles ^=Printer "%~1*"') DO (

IF "%%~B"=="" (

COPY /Y "%%~A" "%~1\" >NUL

) ELSE (

IF /I "%%~A"=="Name:" (

SET Model=%%~B %%~C %%~D %%~E %%~F

>> "%~1\readme.txt" ECHO.%%~A !Model!

)

IF /I "%%~A %%~B %%~C"=="Driver installed from" (

COPY /Y "%%~D" "%~1\" >NUL

SET Inf=%%~nxD

>> "%~1\readme.txt" ECHO.%%~A %%~B %%~C !Inf! %%~E

>> "%~1\install_driver.bat" ECHO :: The following line will install the printer driver for the !Model!

>> "%~1\install_driver.bat" ECHO RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /ia /b"!Model!" /f"%%~dp0!Inf!" /m"!Model!"

)

)

)


:: Close readme.txt

>> "%~1\readme.txt" ECHO Install the driver with install_driver.bat


:: Close install_driver.bat

>> "%~1\install_driver.bat" ECHO POPD


ECHO.

ECHO The printer driver files for the "%Model%" printer

ECHO are copied to the "%~dp0%~1" folder.

ECHO.

ECHO Use install_driver.bat, located in that folder, to (re)install the driver.


ENDLOCAL

GOTO:EOF


:Syntax

ECHO.

IF     "%Matches%"=="0" ECHO ExpPrnDr.bat (Export Printer Drivers),  Version 1.01 for Windows 2000 / XP

IF NOT "%Matches%"=="0" ECHO ExpPrnDr.bat,  Version 1.01 for Windows 2000 / XP

IF NOT "%Matches%"=="0" ECHO Export Printer Drivers

ECHO.

ECHO Usage:  EXPPRNDR  printer

ECHO.

ECHO Where:  "printer"  is (the first part of) the printer name, e.g. "Epson"

ECHO.

ECHO Notes:  This batch file will copy all the files of the specified printer driver

ECHO         to a newly created directory with the specified printer name.

ECHO         This batch file can be used for local printers only.

ECHO         The specified local printer(s) must be connected and switched on.

ECHO         This batch file requires Microsoft's DEVCON to create a list of driver

ECHO         files. If DEVCON is not available, you will be prompted to download it.

ECHO         A batch file "install_driver.bat" will be created in the driver files

ECHO         directory; use that batch file to (re)install the printer driver(s).

ECHO         If multiple printers match the specified name, their drivers will all

ECHO         be stored in a single directory, and "install_driver.bat" will

ECHO         (re)install them all.

ECHO.

ECHO Written by Rob van der Woude

ECHO http://www.robvanderwoude.com


IF "%OS%"=="Windows_NT" ENDLOCAL

IF "%OS%"=="Windows_NT" COLOR 00






Microsoft Download & Info.

https://msdn.microsoft.com/en-us/windows/hardware/drivers/devtest/devcon

https://support.microsoft.com/en-us/help/311272/the-devcon-command-line-utility-functions-as-an-alternative-to-device-manager


http://www.robvanderwoude.com/devcon.php



Have a fun ^^




반응형

이 글을 공유하기

댓글

Designed by JB FACTORY