DEPLOYING A PRINT DRIVER TO MULTIPLE MACHINES AT ONCE…




DEPLOYING A PRINT DRIVER TO MULTIPLE MACHINES AT ONCE…

THIS IS TAKEN FROM COMPUTING.NET FORUMS…

Two days ago we found out 6 of our computers had the wrong driver set for the printer everyone was using. This was causing an issue with printing an extra page with a diamond on it and it was wasting paper. After pondering about it for a little while I found out two ways of reinstalling the printers remotely.

1. Being a administrator you can navigate to the computer in question (computername). Then go into the Printers and Faxes and on the top left is “Add Printer” that will start the Printer Wizard, and it will install on that computer.

But I wanted something faster, easier, and able to do multiple computers.

2. Over the last two days I’ve been working on a script that will install a printer to a remote computer automatically. It uses three batch files to do so. The first file (Printer_Install.bat) starts everything by prompting the user to type the computer name(s) [up to ten] they want to install the printer on. Then it copies the driver files (located in the Drivers folder) to that machine, after it finishes it starts the second file (portcreator.bat) that creates the IP/TCP port that the printer will be using. Finally it starts the last file (printerinstall.bat) and that installs the printer to the machine(s) you specified before. Once you set it up it takes about 10 seconds to transfer a 15mb driver folder, create the port, and install the printer. A lot faster than doing it as stated in number one, especially if you have a lot of computers to do.

As its set right now it’s ready to install a Dell 5310n Laser Printer
using the PCL drivers and creates a port of xxx.xxx.xxx.157. You must use the folder on your local computer and run it from there. (because of size limits on this email i did not include the driver files, but if you read below you can see how to get them.)

—————————————————–

The way to set it up to install different printers and different IP/TCP ports is:

1. If the printer driver is prebuilt into Windows XP all you have to do is change the driver location in the printerinstall.bat to %windir%infntprint.inf then delete the xcopy line, as you do not need to copy any files over to the remote machine.

A. If it’s not a preinstalled driver you must put the driver files into the Drivers folder. When extracting/installing driver files just note the location that they extract to.

2. Right click on Printer_Install.bat and select edit

A. Change the location to where the files will be copied to, do this by changing what is after “%one-ten%c$” but make sure to leave /s/e/i

B. Save and close the file

3. Go into the Batch_Files folder and right click the portcreator.bat file and select edit

A. Change what you want the Port name to be (usually starts with IP_)

B. Then change the IP address to what it’s going to be

C. Save and Close the File

4. Right click the printerinstall.bat file and select edit

A. Change the printer name by changing what is after /b, but keep it in “quotes”

B. change the driver location to where it will be copied to (remember if the printer drivers are preinstalled on win XP change this to %windir%infntprint.inf)

C. Change the port name that it will be installing to the port name you specified before

D. Now change the printer name, this must be the exact name of the printer that is going to be installed. You can find it by looking in the driver .inf file

5. That’s it, now all you have to do it double click the Printer_Install.bat (not the printerinstall.bat that’s in the Batch_Files)

A. when it prompts you, type the computer name(s) [up to ten] you want to install the printer on

B. Sit back and watch

—————————————————-

If you have any questions let me know.

Sincerely,

Sniper62

Folder Setup
——————–
Printer_Install.bat
Batch_Files
Drivers
——————–
Batch_Files
portcreator.bat
printerinstall.bat
psexec.exe
——————-
Drivers
printer driver files
——————-

Psexec
Download it here

Printer_Install.bat

TITLE Dell 5310n Remote Printer Install
@echo off
cls
goto START

********Remote Printer Install Created by***********

Caleb Luehrs

March 2009

****************************************************

:START

@echo off
echo.
echo This will copy the driver files to the computer(s) you want to install this printer on, then create the IP/TCP port, and finally install the Dell 5310n
echo ——————————————————————————–
echo Type the computer name(s) [up to ten] that you want to install this printer on, then press ENTER untill finished then type done to start installation (MAKE SURE YOU ARE USING AN ACCOUNT THAT HAS PERMISSIONS TO ADD A PRINTER)
echo.

SET /P one=Computer 1:

IF %one% EQU exit GOTO EXIT

SET /P two=Computer 2:

IF %two% EQU done GOTO Start

SET /P three=Computer 3:

IF %three% EQU done GOTO Start

SET /P four=Computer 4:

IF %four% EQU done GOTO Start

SET /P five=Computer 5:

IF %five% EQU done GOTO Start

SET /P six=Computer 6:

IF %six% EQU done GOTO Start

SET /P seven=Computer 7:

IF %seven% EQU done GOTO Start

SET /P eight=Computer 8:

IF %eight% EQU done GOTO Start

SET /P nine=Computer 9:

IF %nine% EQU done GOTO Start

SET /P ten=Computer 10:

IF %ten% EQU done GOTO Start

GOTO Start

::================================================================

:Start

xcopy “Drivers” “%one%c$DellDrivers” /s /e /i

Batch_Filespsexec %one% -c Batch_Filesportcreator.bat

Batch_Filespsexec %one% -c Batch_Filesprinterinstall.bat

IF %two% EQU done GOTO Done

GOTO two

:two

xcopy “Drivers” “%two%c$DellDrivers” /s /e /i

Batch_Filespsexec %two% -c Batch_Filesportcreator.bat

Batch_Filespsexec %two% -c Batch_Filesprinterinstall.bat

IF %three% EQU done GOTO Done

GOTO three

:three

xcopy “Drivers” “%three%c$DellDrivers” /s /e /i

Batch_Filespsexec %three% -c Batch_Filesportcreator.bat

Batch_Filespsexec %three% -c Batch_Filesprinterinstall.bat

IF %four% EQU done GOTO Done

GOTO four

:four

xcopy “Drivers” “%four%c$DellDrivers” /s /e /i

Batch_Filespsexec %four% -c Batch_Filesportcreator.bat

Batch_Filespsexec %four% -c Batch_Filesprinterinstall.bat

IF %five% EQU done GOTO Done

GOTO five

:five

xcopy “Drivers” “%five%c$DellDrivers” /s /e /i

Batch_Filespsexec %five% -c Batch_Filesportcreator.bat

Batch_Filespsexec %five% -c Batch_Filesprinterinstall.bat

IF %six% EQU done GOTO Done

GOTO six

:six

xcopy “Drivers” “%six%c$DellDrivers” /s /e /i

Batch_Filespsexec %six% -c Batch_Filesportcreator.bat

Batch_Filespsexec %six% -c Batch_Filesprinterinstall.bat

IF %seven% EQU done GOTO Done

GOTO seven

:seven

xcopy “Drivers” “%seven%c$DellDrivers” /s /e /i

Batch_Filespsexec %seven% -c Batch_Filesportcreator.bat

Batch_Filespsexec %seven% -c Batch_Filesprinterinstall.bat

IF %eight% EQU done GOTO Done

GOTO eight

:eight

xcopy “Drivers” “%eight%c$DellDrivers” /s /e /i

Batch_Filespsexec %eight% -c Batch_Filesportcreator.bat

Batch_Filespsexec %eight% -c Batch_Filesprinterinstall.bat

IF %nine% EQU done GOTO Done

GOTO nine

:nine

xcopy “Drivers” “%nine%c$DellDrivers” /s /e /i

Batch_Filespsexec %nine% -c Batch_Filesportcreator.bat

Batch_Filespsexec %nine% -c Batch_Filesprinterinstall.bat

IF %ten% EQU done GOTO Done

GOTO ten

:ten

xcopy “Drivers” “%ten%c$DellDrivers” /s /e /i

Batch_Filespsexec %ten% -c Batch_Filesportcreator.bat

Batch_Filespsexec %ten% -c Batch_Filesprinterinstall.bat

:Done

echo.
echo.
echo Printer(s) installed succefully!
echo.

pause

goto EXIT

—————————————————————————————————————
To put information into this batch file without having the batch file try to run the information, i had to use
the parameter: goto
i sent the goto to :START (the end of the goto must have : in front of it)
goto is explained below
—————————————————————————————————————

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In order to not have to open up each file and change the computer name, i used the parameters: SET /P whatever=
That will prompt the user to input data, and anywhere in the batch file the command %whatever% is used it will
be put there

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

***************************************************************************************************************

To copy the driver folder from the host system to the target system, i had to use: xcopy
below is a detailed explination of xcopy

***************************************************************************************************************

===============================================================================================================

to execute the port creator and the printer install ON the target machine i had to use a program called psexec
if i did not use psexec and just put the code in those two batch files into one file they would execute on the
host machine.
error 0 means a complete installation without any errors
psexec is explained in detail below

===============================================================================================================

:EXIT

portcreator.bat

TITLE Port Creator
@echo off
goto START

********Remote Printer Install Created by***********

Caleb Luehrs

March 2009

****************************************************

:START

@echo on

cscript C:WINDOWSsystem32prnport.vbs -a -s %COMPUTERNAME% -r IP_xxx.xxx.xxx.157 -h xxx.xxx.xxx.157 -o raw

goto EXIT

—————————————————————————————————————

To put information into this batch file without having the batch file try to run the information, i had to use
the parameter: goto
i sent the goto to :START (the end of the goto must have : in front of it)
goto is explained below

—————————————————————————————————————

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

in order to create a port i had to use: prnport.vbs
windows created this file just for this reason
prnport.vbs is explained more below

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:EXIT

printerinstall.bat

TITLE Printer Install
@echo off
goto START

********Remote Printer Install Created by***********

Caleb Luehrs

March 2009

****************************************************

:START

@echo on

rundll32 printui.dll,PrintUIEntry /if /b “CP OSCAR FUOPS (b/w)” /f C:DellDrivers5310nDKAATC40.inf /r “IP_xxx.xxx.xxx.157″ /m “Dell Laser Printer 5310n”

goto EXIT

—————————————————————————————————————
To put information into this batch file without having the batch file try to run the information, i had to use
the parameter: goto
i sent the goto to :START (the end of the goto must have : in front of it)
—————————————————————————————————————

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

in order to install a printer i had to use: rundll32 printui.dll,PrintUIEntry
you can do alot of different printer things with this utility, for default printers that are prinstalled on Win XP
are located in %windir%infntprint.inf

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:EXIT

    This entry was posted in Network, Print and tagged , , , , , , , , , . Bookmark the permalink.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>