I am looking for a batch-function to check if a printer does already exist on a windows xp system.
I made up the following script:
set PRINTEREXISTS=0
For /F "Tokens=8 delims=\" %%I IN ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers" ^|find /I"r016-printer01"') Do (
echo %%I
set PRINTEREXISTS=1
)
if "%PRINTEREXISTS%"=="0" (
echo Printer doesn't exist
) else (
echo Printer exists
)
However, this sometimes outputs the printer name and then Printer doesn't exist
even though it shouldn't because of PRINTEREXISTS=1
... (NOT an issue of the reg query but with the batch-script somehow)
Any ideas?