0

I want to convert the following code to add the ability to ask for the printers name and IP, to be typed in, either in a pop-up type box or within the console.

Basically, I have to go around to a couple hundred rooms installing a printer in their room locally and want to automate it as much as possible. The driver location is a constant, as well as the script locations.

Unfortunately when it comes to doing stuff like this, I am out of my element. Any help would be greatly appreciated.

@ECHO OFF

REM creating folders on the remote machine to copy the drivers and printer scripts you'll need to install the printer
REM I chose two folders to keep my drivers and scripts separate to keep it simple, you can use one folder if you REM: wish

md C:\DRIVERS
md C:\SCRIPTS

REM Using xcopy to grab the "2kXPVista" file off of the server which contains the .inf and .dll files for the Sharp MX-M623N printer.
REM Most sharp printers have this "2kXPVista" file buried in their driver when you download it from
REM For this particular Sharp MX-M623N printer, our .inf file is "sr0ejenu.inf"
REM If you look in the .inf file for your driver you’ll see the model you need, in our case it’s "SHARP MX-M623N REM: PCL6"

xcopy "\\SERVER\DRIVER_FOLDER\Sharp\MX-M623N\BF2SP-PCL6PS-1104a-2kxpVista-WHQL\EnglishA\PCL6\2kXPVista" C:\DRIVERS /I /y /D

REM /I If destination does not exist and copying more than one file, assumes that destination must be a directory.
REM /Y Suppresses prompting to confirm that you want to overwrite an existing destination file.
REM /D if you want the file or files to be copied to a directory

REM Win7 built in printer scripts
REM cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prndrvr.vbs (adds printer drivers)
REM Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnport.vbs (adds printer port)
REM Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs (ties the name, port, and driver together)

REM I have these three scripts I copy from a server which also work on XP, Vista, and Win7

xcopy "\\rhsdc2\files\scripts" C:\Scripts /I /Y /D

REM The first Prnmngr.vbs is to delete the printer if you're trying to add a printer with the same name
cscript "C:\Scripts\Prnmngr.vbs" -d -p "PHS - Online"

REM Adds a printer port with name "IP_PRINTERIP" and IP address of "PRINTERIP"
Cscript "C:\Scripts\Prnport.vbs" -a -r IP_PRINTERIP -h PRINTERIP -o raw -n 9100

REM Installs the printer driver, first getting the printer model and .inf file, then -h for the path to the .dll
Cscript "C:\Scripts\Prndrvr.vbs" -a -m "SHARP MX-M623N PCL6" -i C:\DRIVERS\sr0ejenu.inf -h C:\DRIVERS

REM Finally giving the printer a name of "PHS - Online", linking the model and printer port
Cscript "C:\Scripts\Prnmngr.vbs" -a -p "PHS - Online" -m "SHARP MX-M623N PCL6" -r IP_PRINTERIP

REM Last, deleting the directories
rd C:\SCRIPTS /s /q
rd C:\DRIVERS /s /q

REM I add the pause in just in case it errors, I will be able to see what it is
@pause
  • Do you have an Active Directory? – Turrican Nov 16 '16 at 17:25
  • 1
    Possible duplicate of [In Windows cmd, how do I prompt for user input and use the result in another command?](http://stackoverflow.com/questions/1223721/in-windows-cmd-how-do-i-prompt-for-user-input-and-use-the-result-in-another-com) – indiv Nov 16 '16 at 19:51
  • That does look like it ties in, however I am unsure as to how that would tie into this. – FinestHops Nov 16 '16 at 20:19
  • As for active directory, yes. However I have looked into active directory methods and because of the layout we have in out AD for user groups, as well as the fact there is a different printer in each room, they just dont seem like they would work out. – FinestHops Nov 16 '16 at 20:22
  • so back to the other... If I wanted to define printer port for example... – FinestHops Nov 16 '16 at 20:23
  • so back to the other... I see many different answers and I cant seem to wrap my head around it. My experience with all this is very limited. So would I execute something like this in the first part of the code for the printer name and IP respectively? set /p var1="Enter first number: " if so, how do I exactly tell it to use those variables in those places? – FinestHops Nov 16 '16 at 20:30
  • `set /p var=prompt` gets user input into %var%. `wmic /node:@"computerlist.txt process call create "cmd /c C:\\folder\\batchfile.bat"` runs a batch file on all computers listed in Computerlist.txt. –  Nov 16 '16 at 21:18
  • Long story short, I figured it out. It works amazing. Part of me figuring it out was actually the link indiv posted and I expanded from that. Cant figure out how to post the finished batch file though. – FinestHops Nov 18 '16 at 19:15

0 Answers0