?
Solved

Need printer .bat or .vbs file

Posted on 2008-11-14
27
Medium Priority
?
713 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:asp_net2
  • 14
  • 10
  • 3
27 Comments
 
LVL 13

Expert Comment

by:mrroonie
ID: 22959785
this has been asked before - http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_20740983.html 

i think a batch file would be easiest
0
 
LVL 4

Author Comment

by:asp_net2
ID: 22959862
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.
0
 
LVL 13

Expert Comment

by:mrroonie
ID: 22959928
Is the printer directly on the |LAN or shared thru a PC?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:asp_net2
ID: 22959930
directly on the LAN
0
 
LVL 13

Expert Comment

by:mrroonie
ID: 22960003
maybe vbs would be your best option then - http://forums.techarena.in/xp-print-fax/937795.htm
0
 
LVL 4

Author Comment

by:asp_net2
ID: 22960062
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.
0
 
LVL 4

Author Comment

by:asp_net2
ID: 22960556
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
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22962443
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

0
 
LVL 4

Author Comment

by:asp_net2
ID: 22962476
:( Still no luck. When i double click on the .bat file it just flashes and nothing else happens.
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22962674
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

0
 
LVL 4

Author Comment

by:asp_net2
ID: 22962735
almost there :) now when i run it i recieve the following error below.

"The arguments are invalid"
0
 
LVL 4

Author Comment

by:asp_net2
ID: 22963007
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.
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22963286
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.



0
 
LVL 4

Author Comment

by:asp_net2
ID: 22963318
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.
0
 
LVL 4

Author Comment

by:asp_net2
ID: 22963376
i added the drivers to my NAS box and still get the same error message.
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22963520
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

0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22963544
Oh yeah I also included quotes in the cscript command line.
0
 
LVL 4

Author Comment

by:asp_net2
ID: 22963554
:(  Same thing!
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22963616
The port should be created.
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22963765
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

0
 
LVL 21

Accepted Solution

by:
AmazingTech earned 2000 total points
ID: 22963799
Opps. Missed the quotes again. OK. I'm changing all sets so they are consistent.
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

0
 
LVL 4

Author Comment

by:asp_net2
ID: 22964241
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?
0
 
LVL 4

Author Comment

by:asp_net2
ID: 22979341
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??
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22979397
.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.
0
 
LVL 4

Author Comment

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

thanks in advance!!
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22980884
Yup those keywords should do. Also "Batch files"
0
 
LVL 4

Author Closing Comment

by:asp_net2
ID: 31516776
Thanks again for all  your help and patients!!!

Take care!!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question