SHOW:
|
|
- or go back to the newest paste.
1 | @echo off | |
2 | echo **YOU MUST BE AN ADMINISTRATOR ON THIS MACHINE FOR THE SCRIPT TO WORK PROPERLY** | |
3 | echo THIS SCRIPT WORKS FOR WINDOWS XP AND WINDOWS 7 | |
4 | REM This determines if you're running XP or Windows 7 | |
5 | ver | find "XP" > nul | |
6 | if %errorlevel% == 1 goto :win7 | |
7 | break | |
8 | REM This runs if XP is found. The Windows 7 commands are at the bottom of this script | |
9 | echo IDENTIFIED WINDOWS XP | |
10 | echo Checking if printer "[PRINTER NAME HERE]" already exists | |
11 | REM This command checks your registry for the printer you're installing. | |
12 | REM The goto command only completes if the registry entry is found | |
13 | set Key=hklm\system\controlset001\control\print\printers | |
14 | reg query %Key%"\[PRINTER NAME HERE]" /v Name && goto :exists | |
15 | break | |
16 | REM This creates the local IP port for the printer's address | |
17 | echo INSTALLING IP PRINTER PORT [PRINTER IP HERE] | |
18 | cscript %windir%\system32\prnport.vbs -a -r "IP_[PRINTER IP HERE]" -h [PRINTER IP HERE] -o raw | |
19 | REM This verifies the command completed successfully, otherwise it stops the script | |
20 | if errorlevel 1 goto :end | |
21 | break | |
22 | echo INSTALLING PRINTER "[PRINTER NAME HERE]" | |
23 | REM This uses the printui.dll to install the printer driver from the command line | |
24 | 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]" | |
25 | if errorlevel 0 goto :successful | |
26 | if errorlevel 1 goto :error | |
27 | :successful | |
28 | break | |
29 | break | |
30 | echo THE PRINTER IS SUCCESSFULLY INSTALLED | |
31 | pause | |
32 | goto :end | |
33 | pause | |
34 | :error | |
35 | break | |
36 | break | |
37 | echo ERRORS WERE FOUND. THE PRINTER DID NOT INSTALL | |
38 | pause | |
39 | goto :end | |
40 | :exists | |
41 | break | |
42 | echo THE PRINTER ALREADY EXISTS. NO CHANGES WERE MADE. | |
43 | pause | |
44 | goto :end | |
45 | REM These commands are the same as the commands above, but tailored for the differences in paths and | |
46 | REM drivers for Windows 7 | |
47 | :win7 | |
48 | echo IDENTIFIED WINDOWS 7 | |
49 | break | |
50 | echo CHECKING IF PRINTER "[PRINTER NAME HERE]" already exists | |
51 | set Key=hklm\system\controlset001\control\print\printers | |
52 | reg query %Key%"\[PRINTER NAME HERE]" /v Name && goto :exists | |
53 | break | |
54 | echo INSTALLING IP PRINTER PORT [PRINTER IP HERE] | |
55 | cscript %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r "IP_[PRINTER IP HERE]" -h [PRINTER IP HERE] -o raw | |
56 | if errorlevel 1 goto :error | |
57 | echo INSTALLING PRINTER "[PRINTER NAME HERE]" | |
58 | 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]" | |
59 | if errorlevel 0 goto :successful | |
60 | if errorlevel 1 goto :error | |
61 | pause | |
62 | :end |