Installing a Printer via Batch File

Hewlett-packard / 2300
January 20, 2009 at 04:51:35
Specs: Windows XP, P4 2.8GHz
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


See More: Installing a Printer via Batch File

Report •


#1
January 20, 2009 at 23:13:37
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.


Report •
Related Solutions


Ask Question