Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- echo **YOU MUST BE AN ADMINISTRATOR ON THIS MACHINE FOR THE SCRIPT TO WORK PROPERLY**
- echo THIS SCRIPT WORKS FOR WINDOWS XP AND WINDOWS 7
- REM This determines if you're running XP or Windows 7
- ver | find "XP" > nul
- if %errorlevel% == 1 goto :win7
- break
- REM This runs if XP is found. The Windows 7 commands are at the bottom of this script
- echo IDENTIFIED WINDOWS XP
- echo Checking if printer "[PRINTER NAME HERE]" already exists
- REM This command checks your registry for the printer you're installing.
- REM The goto command only completes if the registry entry is found
- set Key=hklm\system\controlset001\control\print\printers
- reg query %Key%"\[PRINTER NAME HERE]" /v Name && goto :exists
- break
- REM This creates the local IP port for the printer's address
- echo INSTALLING IP PRINTER PORT [PRINTER IP HERE]
- cscript %windir%\system32\prnport.vbs -a -r "IP_[PRINTER IP HERE]" -h [PRINTER IP HERE] -o raw
- REM This verifies the command completed successfully, otherwise it stops the script
- if errorlevel 1 goto :end
- break
- echo INSTALLING PRINTER "[PRINTER NAME HERE]"
- REM This uses the printui.dll to install the printer driver from the command line
- rundll32 printui.dll,PrintUIEntry /if /r "IP_[PRINTER IP HERE]" /b "[PRINTER NAME HERE]" /f "[PATH TO THE PRINT DRIVER .INF FILE HERE].inf" /m "[SPECIFY THE DRIVER WITHIN THE INF FILE HERE]"
- if errorlevel 0 goto :successful
- if errorlevel 1 goto :error
- :successful
- break
- break
- echo THE PRINTER IS SUCCESSFULLY INSTALLED
- pause
- goto :end
- pause
- :error
- break
- break
- echo ERRORS WERE FOUND. THE PRINTER DID NOT INSTALL
- pause
- goto :end
- :exists
- break
- echo THE PRINTER ALREADY EXISTS. NO CHANGES WERE MADE.
- pause
- goto :end
- REM These commands are the same as the commands above, but tailored for the differences in paths and
- REM drivers for Windows 7
- :win7
- echo IDENTIFIED WINDOWS 7
- break
- echo CHECKING IF PRINTER "[PRINTER NAME HERE]" already exists
- set Key=hklm\system\controlset001\control\print\printers
- reg query %Key%"\[PRINTER NAME HERE]" /v Name && goto :exists
- break
- echo INSTALLING IP PRINTER PORT [PRINTER IP HERE]
- cscript %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r "IP_[PRINTER IP HERE]" -h [PRINTER IP HERE] -o raw
- if errorlevel 1 goto :error
- echo INSTALLING PRINTER "[PRINTER NAME HERE]"
- rundll32 printui.dll,PrintUIEntry /if /r "IP_[PRINTER IP HERE]" /b "[PRINTER NAME HERE]" /f "[FULL PATH TO PRINTER DRIVER INF FILE].inf" /m "[SPECIFIC DRIVER IN THE INF FILE]"
- if errorlevel 0 goto :successful
- if errorlevel 1 goto :error
- pause
- :end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement