Link to home
Start Free TrialLog in
Avatar of Brian
BrianFlag for United States of America

asked on

Need printer .bat or .vbs file

Hello,

I would like to be able to have a user double click on either a .bat file or .vbs file to install a local printer on our LAN. Below is the information.

IP: 10.0.6.10
Name: Cannon iR 6570
Driver Path: \\nas1\Drivers\Printer\CannoniR6570

Avatar of mrroonie
mrroonie
Flag of United Kingdom of Great Britain and Northern Ireland image

this has been asked before - https://www.experts-exchange.com/questions/20740983/install-printer-using-dos-batch-file.html 

i think a batch file would be easiest
Avatar of Brian

ASKER

I don't have a print server. The printer is just is part of the LAN. All IT staff has to manually select TCP/IP from port and then enter IP address and then add the path for the printer driver. It would be nice for all this info to be in either a .bat file or .vbs file.
Is the printer directly on the |LAN or shared thru a PC?
Avatar of Brian

ASKER

directly on the LAN
maybe vbs would be your best option then - http://forums.techarena.in/xp-print-fax/937795.htm
Avatar of Brian

ASKER

I know how to use GOOGLE to. I saw that tutorial already and i'm only working with one printer and do not want to delete other printers installed. Please let me know if you can't help anymore with this. I have GOOGLE enough sites and looking for help/examples.
Avatar of Brian

ASKER

i have tried the following below from Post 22960003 but it will not install my printer that is connected to our LAN.


SET P1=%PRINTER1
IF NOT EXIST C:\TEMP\%P1%.TXT GOTO :I1
GOTO :EOF
I1
SET P1=%HP LaserJet10.0.10.19
SET PIP1=%110.0.10.19
SET PNAME1=%"HP LaserJet 4250dtn"
SET PDRIVER1=%"C:\Documents and Settings\user\Desktop\hpc4x50b.ini"
cscript.exe c:\windows\system32\prnport.vbs -a -r %P1% -h %PIP1% -o raw -n 9100
rundll32 printui.dll PrintUIEntry /if /b %P1% /f %PDRIVER1% /r %P1% /m %PNAME1% /z
P1 > C:\TEMP\%P1%.TXT
Avatar of AmazingTech
AmazingTech

What are those %s for?

Try it this.
SET P1=PRINTER1
IF NOT EXIST C:\TEMP\%P1%.TXT GOTO :I1
GOTO :EOF
I1
SET P1=HP LaserJet10.0.10.19
SET PIP1=110.0.10.19
SET PNAME1="HP LaserJet 4250dtn"
SET PDRIVER1="C:\Documents and Settings\user\Desktop\hpc4x50b.ini"
cscript.exe c:\windows\system32\prnport.vbs -a -r %P1% -h %PIP1% -o raw -n 9100
rundll32 printui.dll PrintUIEntry /if /b %P1% /f %PDRIVER1% /r %P1% /m %PNAME1% /z 
ECHO P1 > C:\TEMP\%P1%.TXT

Open in new window

Avatar of Brian

ASKER

:( Still no luck. When i double click on the .bat file it just flashes and nothing else happens.
Opps the label was setup properly.
SET P1=PRINTER1
IF NOT EXIST C:\TEMP\%P1%.TXT GOTO :I1
GOTO :EOF
:I1
SET P1=HP LaserJet10.0.10.19
SET PIP1=110.0.10.19
SET PNAME1="HP LaserJet 4250dtn"
SET PDRIVER1="C:\Documents and Settings\user\Desktop\hpc4x50b.ini"
cscript.exe c:\windows\system32\prnport.vbs -a -r %P1% -h %PIP1% -o raw -n 9100
rundll32 printui.dll PrintUIEntry /if /b %P1% /f %PDRIVER1% /r %P1% /m %PNAME1% /z 
ECHO P1 > C:\TEMP\%P1%.TXT

Open in new window

Avatar of Brian

ASKER

almost there :) now when i run it i recieve the following error below.

"The arguments are invalid"
Avatar of Brian

ASKER

okay i made a little change and got a different message below.

Operation could not be completed. Windows cannot locate a suitable printer driver. Contact your system admiistrator for help locating and installing a suitable driver.
I think:

SET PDRIVER1="C:\Documents and Settings\user\Desktop\hpc4x50b.ini"

Should point to an .inf file. Maybe putting the printer driver on a server share is a better idea too.



Avatar of Brian

ASKER

yeah, i saw that mistake and fixed it but got the same error message. What i did was i went to HP's site and extracted all files on my desktop so that i can try to get this to work with the drivers on my machine and the printer is on my LAN.
Avatar of Brian

ASKER

i added the drivers to my NAS box and still get the same error message.
OK. How about this?

Need quotes in rundll32.

I thin this is wrong too

SET PIP1=10.0.10.19

SET P1=PRINTER1
IF NOT EXIST C:\TEMP\%P1%.TXT GOTO :I1
GOTO :EOF
:I1
SET P1=HP LaserJet10.0.10.19
SET PIP1=10.0.10.19
SET PNAME1="HP LaserJet 4250dtn"
SET PDRIVER1="C:\Documents and Settings\user\Desktop\hpc4x50b.inf"
cscript.exe c:\windows\system32\prnport.vbs -a -r "%P1%" -h "%PIP1%" -o raw -n 9100
rundll32 printui.dll PrintUIEntry /if /b "%P1%" /f %PDRIVER1% /r "%P1%" /m %PNAME1% /z 
ECHO P1 > C:\TEMP\%P1%.TXT

Open in new window

Oh yeah I also included quotes in the cscript command line.
Avatar of Brian

ASKER

:(  Same thing!
The port should be created.
Ok. Downloaded the PCL6 driver. You need to reference the name of the driver that's inside the inf file.

SET P1=PRINTER1
IF NOT EXIST C:\TEMP\%P1%.TXT GOTO :I1
GOTO :EOF
:I1
SET P1=HP LaserJet10.0.10.19
SET PIP1=10.0.10.19
SET PNAME1="HP LaserJet 4250dtn"
SET PDRIVERNAME1="HP LaserJet 4250 PCL 6"
SET PDRIVER1="C:\HP LJ4200-4300 Series PCL6 Driver\hpc4x50c.inf"
cscript.exe c:\windows\system32\prnport.vbs -a -r "%P1%" -h "%PIP1%" -o raw -n 9100
rundll32 printui.dll PrintUIEntry /if /b %PNAME1% /f %PDRIVER1% /r "%P1%" /m %PDRIVERNAME1% /z 
ECHO P1 > C:\TEMP\%P1%.TXT

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of AmazingTech
AmazingTech

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brian

ASKER

NICE!!! That worked out GREAT. Your title fits your skills. It did work but the only little anoying problem is that i had to close the dos command window. Also, is there a switch to make that the default printer?
Avatar of Brian

ASKER

Hi AmazingTech,

Everything worked out great as i needed. I only have to ask you a dumb question. What type of language is being used here in this .bat file??
.bat or .cmd is DOS batch scripting. Essentially when you open a command prompt and type in a command you can put all those individual commands together in a .bat or .cmd to run them sequentially.
Avatar of Brian

ASKER

okay, so if i want to learn more would i google "DOS batch scripting" or .bat or .cmd scription?

thanks in advance!!
Yup those keywords should do. Also "Batch files"
Avatar of Brian

ASKER

Thanks again for all  your help and patients!!!

Take care!!