(view source code of addipprn.bat as plain text)
@ECHO OFF
:: Check Windows version
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
SETLOCAL
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
:: ::
:: Modify the following lines; no quotes for PrnShort and PortIP! ::
:: ::
:: The values for PrnType and TargetOS can be found in the INF file ::
:: that comes with the (extracted) printer driver. ::
:: ::
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
SET PrnName="Accounting 2nd Floor"
SET PrnShort=Accounting2
SET PrnType="Kyocera Mita FS-3820N"
SET DrvPath="\\server\share\Drivers\Kyocera\FS-3820N\W2K"
SET InfPath="\\server\share\Drivers\Kyocera\FS-3820N\W2K\oemsetup.inf"
SET PortIP=112.113.114.115
SET TargetOS="Windows 2000"
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
:: ::
:: End of adjustments ::
:: ::
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
:: Check command line arguments
IF "%~1"=="" GOTO Syntax
SET PC=%~1
ECHO."%PC%" | FINDSTR.EXE /R /C:"[?/]" >NUL && GOTO Syntax
PING.EXE %PC% 2>NUL | FIND.EXE "TTL=" >NUL || (
ECHO Computer %PC% is unavailable
ECHO.
GOTO Syntax
)
:: Check if the required VBScripts are available in the current directory
SET Error=0
FOR %%A IN (prncfg prnmgr drvmgr portmgr) DO IF NOT EXIST %%A.vbs SET Error=1
IF "%Error%"=="1" GOTO Syntax
:: Check if the printer was installed already
CSCRIPT.EXE //NoLogo prnmgr.vbs -l -c \\%PC% | FIND.EXE /I "%PrnShort%" >NUL && (
ECHO A printer named %PrnShort% already exists on %PC%
ECHO.
GOTO Syntax
)
:: Check if the printer port was installed already
CSCRIPT.EXE //NoLogo portmgr.vbs -l -c \\%PC% | FINDSTR.EXE /E /I "IP_%PortIP%" >NUL && (
ECHO TCP/IP printer port %PortIP% already exists on %PC%
ECHO.
GOTO Syntax
)
:: Prompt the user, and allow him/her to abort the installation
ECHO You are about to add a local printer %PrnShort% on computer %PC%
ECHO.
PAUSE
:: Install the driver
CSCRIPT.EXE //NoLogo drvmgr.vbs -a -c \\%PC% -p %DrvPath% -i %InfPath% -v %TargetOS% -m %PrnType% -t Intel
:: Install the local IP print port, type raw, SNMP disabled
CSCRIPT.EXE //NoLogo portmgr.vbs -a -c \\%PC% -p IP_%PortIP% -h %PortIP% -t raw -n 9100 -md
:: Install the local printer with the driver and port we just installed
CSCRIPT.EXE //NoLogo prnmgr.vbs -a -c \\%PC% -b %PrnName% -m %PrnType% -r IP_%PortIP%
:: Configure the local printer as not shared and not published in Active Directory
CSCRIPT.EXE //NoLogo prncfg.vbs -s -b \\%PC%\%PrnShort% -published -shared
:: Display or log the configuration of the new printer
IF /I "%~2"=="/L" (SET Log="%PrnShort%_%PC%.log") ELSE (SET Log=CON)
(
CSCRIPT.EXE //NoLogo drvmgr.vbs -l -c \\%PC%
CSCRIPT.EXE //NoLogo portmgr.vbs -l -c \\%PC%
CSCRIPT.EXE //NoLogo prnmgr.vbs -l -c \\%PC%
CSCRIPT.EXE //NoLogo prncfg.vbs -g -b \\%PC%\%PrnShort%
) > %Log% 2>&1
:: Done
GOTO End
:Syntax
ECHO.
ECHO AddIPPrn.bat, Version 1.01 for Windows 2000 with Server Resource Kit
ECHO Install a (hard coded) local IP printer %PrnShort% on a remote computer
ECHO.
ECHO Usage: ADDIPPRN.BAT computername [ /L ]
ECHO.
ECHO Where: "computername" is the computer on which the printer should be installed
ECHO "/L" logs the results in {printername}_{computername}.log
ECHO (default is display on screen)
ECHO.
ECHO Notes: [1] You need to modify the first couple of lines from this batch file
ECHO to install your own printer, port and driver. You may then want
ECHO to save the modified batch file as {printername}.bat.
ECHO [2] This batch file requires drvmgr.vbs, portmgr.vbs, prnmgr.vbs and
ECHO prncfg.vbs from the Windows 2000/2003 Server Resource Kit; these
ECHO scripts must all be located in the current directory.
ECHO [3] These VBScripts require PRNADMIN.DLL from the Resource Kit to be
ECHO installed on the computer that runs the scripts.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
:End
IF "%OS%"=="Windows_NT" ENDLOCAL
page last modified: 2024-04-16; loaded in 0.0085 seconds