Computing.Net > Forums > Programming > Installing a Printer via Batch File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Installing a Printer via Batch File

Reply to Message Icon

Name: mtk1986
Date: January 20, 2009 at 04:51:35 Pacific
OS: Windows XP
CPU/Ram: P4 2.8GHz
Product: Hewlett-packard / 2300
Subcategory: Batch
Comment:

Hey all,

I am currently working on a BATCH file that will install a specific printer (on a printserver) to a computer. The current script looks is this:...

______________________________
@Echo off

REM this command file will add a network printer to a computer remotely

REM the parameters are:

REM 1 - the name of the computer to which the network printer is to be added
REM 2 - the UNC name of the printer to be added

REM for example, to add the printer called ThePrinter that is shared from the computer PrintServer
REM to the computer called TheClient:

REM key this command in a Command Prompt window:

REM addglobalprinterremotely theclient printserver\theprinter


REM add the specified printer to the specified computer
@Echo On
rundll32 printui.dll,PrintUIEntry /ga /c\\beit032 /n\\printserver\153_ca_hp2015
@Echo off
REM stop the print spooler on the specified computer and wait until the sc command finishes
@Echo On
start /wait sc \\beit032 stop spooler
@Echo off
REM start the print spooler on the specified computer and wait until the sc command finishes
@Echo On
start /wait sc \\beit032 start spooler

pause

______________________________

What I am after acheiveing is to be prompted for the following information..

1: PC Name (where the Printer will be installed - in the script as "\\beit032")
2: The printer. (in the script as "\\printserver\153_ca_hp2015")

I have tried a few methods but just cant get it to work.

Any help on this would be great.

Thanks in advance.
Martyn



Sponsored Link
Ads by Google

Response Number 1
Name: Holla
Date: January 20, 2009 at 23:13:37 Pacific
Reply:

Martyn,
your question is not clear to me.
I guess you want a mechanism to take user input and use the input strings in the batch command?
Then this would work:


set /p PCName=Enter PC name:
:Use %PCName% in the rest of the script to refer to the user entered string
:Similarly, you can get printer name from user.
: You can also enumerate available printers from the "net view \\servername" command.
: Ex:for /f "tokens=1,2 delims= " %A in ('net view \\servername') do if %B==Print Echo %A is a printer

--
Holla.


0
Reply to Message Icon

Related Posts

See More


xcopy folder disappearing... email input forms from Ou...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Installing a Printer via Batch File

Recommendations for a Book on Batch Files www.computing.net/answers/programming/recommendations-for-a-book-on-batch-files/19543.html

Path via Batch File www.computing.net/answers/programming/path-via-batch-file/7923.html

installing a printer driver through www.computing.net/answers/programming/installing-a-printer-driver-through/14159.html