::
:: NETWORK RRINTER > LPT MOUNT
:: BYLEE 20101222
::
::
:: ERRORLEVEL로는 폼즈와 여동 불가능해서
:: SETX 명령어를 통해 환경변수 > 시스템 변수로 NPS_LEVEL 인자값을 등록해서 통신한다.
:: 결국 프린터 체크 결과값을 TXT 파일로 저장. 저장 PATH 는 환경파일에서 읽어드리기..
::
@echo off
color 3f
title NETWORK PRINTER CHECK
CLS
if "%1" == "" goto exit9
if "%2" == "" goto exit9
if "%3" == "" goto exit9
SET LPTNM=%1
SET PRTIP=%2
SET PRTNM=%3
SET CFGNM=LPTS.CFG
SET/P CFGNM=< "PRTCHK.CFG"
:: 유효성 체크 추가
:: 매칭 안될시 삭제____________________________________________________
NET USE %LPTNM% >NUL 2>&1
if not %ERRORLEVEL% == 0 goto START
net use|find /I "%LPTNM%"|find /I "%PRTIP%\%PRTNM%" >nul 2>&1
if %ERRORLEVEL% == 0 goto START
:: 삭제
net use %LPTNM% /D >nul 2>&1
:START
SETX NPS_LEVEL 0 /M >NUL 2>&1
::-----------------------------------------------------------------------
:: 1.상태체크
net use %LPTNM% >NUL 2>&1
if %ERRORLEVEL% == 0 goto SEQ2
:: seq1 ________________________________________________________________________________________________
:: 장비 자체가 마운트 X
net view \\%PRTIP% >nul 2>&1
if not %ERRORLEVEL% == 0 goto EXIT1
NET VIEW \\%PRTIP%|FIND "%PRTNM%" >nul 2>&1
if not %ERRORLEVEL% == 0 goto EXIT3
NET USE %LPTNM% \\%PRTIP%\%PRTNM% /P=Y >nul 2>&1
if not %ERRORLEVEL% == 0 goto EXIT4
GOTO END
:: seq2 / 장치가 마운트 되어 있음 _______________________________________________________________________
:SEQ2
NET USE %LPTNM%|FIND "상태"|FIND "OK" >nul 2>&1
if %ERRORLEVEL% == 0 goto SEQ2_2
NET USE %LPTNM%|FIND "상태"|FIND "끊김" >nul 2>&1
if not %ERRORLEVEL% == 0 goto SEQ2_12
:: LPT 상태:연결끊김
:SEQ2_11
NET VIEW \\%PRTIP% >nul 2>&1
if not %ERRORLEVEL% == 0 goto EXIT1
goto end
:: LPT 상태:사용못함
:SEQ2_12
NET USE %LPTNM% \\%PRTIP%\%PRTNM% /P=Y >nul 2>&1
if not %ERRORLEVEL% == 0 goto EXIT4
goto end
:: LPT 마운트 정상. 상태 정상 ++++++++++++++++++++
:SEQ2_2
NET VIEW \\%PRTIP% >nul 2>&1
if not %ERRORLEVEL% == 0 goto EXIT1
GOTO END
goto end
:::__________________________________________________________________________________________________
:: 네트워크 오류(REAL)
:EXIT1
::SETX NPS_LEVEL 1 /M >NUL 2>&1
echo 1 > %CFGNM%
exit /b 1
:: 네트워크 오류(STAT)
:EXIT2
::SETX NPS_LEVEL 2 /M >NUL 2>&1
echo 2 > %CFGNM%
exit /b 2
:: 서버장치가 존재하지 않음
:EXIT3
::SETX NPS_LEVEL 3 /M >NUL 2>&1
echo 3 > %CFGNM%
exit /b 3
:: 장치 마운트 실패
:EXIT4
::SETX NPS_LEVEL 4 /M >NUL 2>&1
echo 4 > %CFGNM%
exit /b 4
:EXIT9
cls
color 4f
echo.
echo #Error :
echo Please !! Check the Batch parameters (1,2,3)
echo ex) prtchk lpt1 192.168.0.110 HPLaserJ
echo.
::SETX NPS_LEVEL 9 /M >NUL 2>&1
echo 9 > %CFGNM%
exit /b 9
:END
::SETX NPS_LEVEL 0 /M >NUL 2>&1
echo 0 > %CFGNM%
exit /b 0
댓글 없음:
댓글 쓰기