
Estou habilitado para verificar se a pasta de rede existe
IF EXIST \\192.168.1.2\SharedFolder\ (echo It exist)
mas não estou habilitado para verificar se existe uma impressora de rede.
IF EXIST \\192.168.1.2\printername (echo It exist)
Responder1
A seguirroteiro de Robvanderwoude.comtestes para a existência de uma impressora:
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
Responder2
Encontrei este tópico enquanto procurava uma maneira de melhorar meu deleteprinters.bat para contornar essas mensagens pop-up "Impressora não encontrada", que estão interrompendo meu script.
Mas, neste caso, a maneira mais fácil de lidar com isso é apenas adicionar o parâmetro /q após RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry.
Apenas no caso de.