배치: 네트워크 공유 프린터가 있는지 어떻게 확인하나요?

배치: 네트워크 공유 프린터가 있는지 어떻게 확인하나요?

네트워크 폴더가 있는지 확인할 수 있습니다.

IF EXIST \\192.168.1.2\SharedFolder\ (echo It exist)

하지만 네트워크 프린터가 존재하는지 확인하는 기능은 활성화되어 있지 않습니다.

IF EXIST \\192.168.1.2\printername (echo It exist)

답변1

다음과 같은Robvanderwoude.com의 스크립트프린터 존재 여부를 테스트합니다.

REM NOTE: RUNDLL32.exe and PRINTUI.exe always return Errorlevel=0
REM The trick: Try to get the printer settings into a file
REM If No file is created = The Printer does not exist
SET PrinterName=FIT FP-32L Raster
SET TESTfile=%TEMP%\PrtExist.txt

REM Delete %TESTfile% to avoid false positives
DEL %TESTfile% /F /Q

REM Try to get the printer settings into a file
RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Xg /n "%PrinterName%" /f "%TESTfile%" /q

IF EXIST "%TESTfile%" (
    ECHO %PrinterName% printer exists
) ELSE (
    ECHO %PrinterName% printer does NOT exists
)

PAUSE

답변2

스크립트를 방해하는 "프린터를 찾을 수 없음"이라는 팝업 메시지를 해결하기 위해 deleteprinters.bat를 개선하는 방법을 검색하는 동안 이 주제를 발견했습니다.

하지만 이 경우 이를 처리하는 가장 쉬운 방법은 RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry 뒤에 /q 매개변수를 추가하는 것입니다.

혹시라도.

관련 정보