(view source code of isduplexprinter.bat as plain text)
@ECHO OFF
IF "%~1"=="/?" GOTO Syntax
SETLOCAL ENABLEDELAYEDEXPANSION
IF "%~1"=="" (
FOR /F "tokens=1* delims==" %%A IN ('WMIC.EXE Path Win32_Printer WHERE Default^=TRUE Get Name /Format:value ^| FIND.EXE "="') DO (
FOR /F "tokens=1*" %%C IN ("%%~B") DO (
SET PrinterName="%%~C"
)
)
) ELSE (
FOR /F "tokens=1* delims==" %%A IN ('WMIC.EXE Path Win32_Printer WHERE Name^="%~1" Get Name /Format:value ^| FIND.EXE "="') DO (
FOR /F "tokens=1*" %%C IN ("%%~B") DO (
SET PrinterName="%%~C"
)
)
)
IF NOT DEFINED PrinterName (
ECHO Unknown printer name
ENDLOCAL
EXIT /B -1
)
WMIC.EXE Path Win32_Printer WHERE Name^=%PrinterName% Get Capabilities | FINDSTR.EXE /R /C:"[{ ,]3[} ,]" >NUL
SET /A RC = 1 - %ErrorLevel%
IF "%RC%"=="1" (
ECHO Printer %PrinterName% IS duplex capable
) ELSE (
ECHO Printer %PrinterName% is NOT duplex capable
)
ENDLOCAL & EXIT /B %RC%
:Syntax
ECHO.
ECHO IsDuplexPrinter.bat, Version 1.00
ECHO Check if a printer is capable of duplex ^(two-sided^) printing
ECHO.
ECHO Usage: IsDuplexPrinter.bat [ "printer" ]
ECHO.
ECHO Where: "printer" is the optional name of the printer to be checked
ECHO ^(default: the default printer^)
ECHO.
ECHO Returns: On screen message stating if the printer is duplex capable.
ECHO Return code 1 if duplex capable, 0 if not, -1 in case of errors.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
EXIT /B -1
page last modified: 2024-04-16; loaded in 0.0099 seconds