(view source code of addprint.bat as plain text)
@ECHO OFF
VER | FIND "Windows 2000" >NUL
IF ERRORLEVEL 1 GOTO Syntax
SETLOCAL
SET Printer=%1
SET RemotePC=%2
:: Check printer specified
IF NOT DEFINED Printer GOTO Syntax
IF NOT "%Printer:~0,2%"=="\\" GOTO Syntax
FOR /F "tokens=1* delims=\" %%A IN ('ECHO.%Printer%') DO (
SET PrintServer=%%A
Set PrintShare=%%B
)
IF NOT DEFINED PrintShare GOTO Syntax
PING %PrintServer% -n 1 -w 1000 2>&1 | FIND "TTL=" >NUL
IF ERRORLEVEL 1 GOTO Syntax
NET VIEW \\%PrintServer% 2>&1 | FIND /I "%PrintShare%" >NUL
IF ERRORLEVEL 1 GOTO Syntax
:: Check remote PC if specified
IF DEFINED RemotePC SET RemotePC=%RemotePC:\=%
IF DEFINED RemotePC (
PING %RemotePC% -n 1 -w 1000 2>&1 | FIND "TTL=" >NUL
IF ERRORLEVEL 1 GOTO Syntax
SET RemotePC=/C\\%RemotePC%
)
:: Install the printer on the specified computer
RUNDLL32.EXE PRINTUI.DLL, PrintUIEntry /ga /n%Printer% %RemotePC%
IF NOT ERRORLEVEL 1 ECHO Printer installed, please reboot %RemotePC%
ENDLOCAL
GOTO:EOF
:Syntax
ECHO.
ECHO AddPrint.bat, Version 1.01 for Windows 2000
ECHO Install a network printer on any PC on the network
ECHO.
ECHO Usage: ADDPRINT \\print_server\printer_share [ remote_pc ]
ECHO.
ECHO Where: "print_server" is the print server name or IP address
ECHO "printer_share" is the share name for the printer
ECHO "remote_pc" is the PC that will be using the
ECHO network printer -- default is local PC
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
IF "%OS%"=="Windows_NT" ENDLOCAL
page last modified: 2024-04-16; loaded in 0.0094 seconds