Solved

Setting up printer via scripts

Posted on 2007-03-22
9
172 Views
Last Modified: 2010-08-05
Great Day EXPERTS!
I have been tasked with the job of moving 50 people this weekend in into new office. A great portion of people will be receiving new machine. Therefore, I will have to setup all there printer again. I now you are wondering why aren’t we using roaming profile, it was not my decision but my boss and other coworkers. So I was wondering is there a script out on the web that I can uses that will allow me to place on the desktop and all they would have to do is select the icon script and it will load all the printer on the network or just this location or can one be written for me.

0
Comment
Question by:melvinsanders
  • 4
  • 4
9 Comments
 
LVL 21

Expert Comment

by:mastoo
ID: 18773407
You can make a batch file that holds commands like this to add network printers:

prnmngr -ac -p "\\server\printer"
0
 

Author Comment

by:melvinsanders
ID: 18773720
I am not sure how to write a batch file that would allow me to do so.
0
 
LVL 21

Expert Comment

by:mastoo
ID: 18774050
Use wordpad to create a text file called MyPrnt.cmd
Edit it to contain this line but fill in the name of the server and printer you want to add:

prnmngr -ac -p "\\server\printer"

Close wordpad.  To test it, open a command prompt, go to the directory you put MyPrnt.cmd in, type MyPrnt.cmd to run it, see what happens.  If that works, then it should work if you copy the file to somebody's desktop and they double-click it from there.
0
 

Author Comment

by:melvinsanders
ID: 18774185
I am sorry I went to the cmd prompt and nothing happened. I copied the info to word pad ran it and something flashed for a sec. I check the printer and faxes to see if it added the printer i sorry and it did not.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:melvinsanders
ID: 18774401
Can you try this, I am running 2003 server my dcsvr name is be dcsvr1 printer name HQ-CanonIR8500. I I have tried the batch file you sent it did not work for me or i just did not do it right therefore can you type it up.


@ECHO OFF
VER | FIND "Windows 2000" >NUL
IF ERRORLEVEL 1 GOTO Syntax

SETLOCAL
SET Printer=%1
SET RemotePC=%2

:: Check printer specified
IF NOT DEFINED Printer GOTO Syntax
IF NOT "%Printer:~0,2%"=="\\" GOTO Syntax
FOR /F "tokens=1* delims=\" %%A IN ('ECHO.%Printer%') DO (
      SET PrintServer=%%A
      Set PrintShare=%%B
)
IF NOT DEFINED PrintShare GOTO Syntax
PING %PrintServer% -n 1 -w 1000 2>&1 | FIND "TTL=" >NUL
IF ERRORLEVEL 1 GOTO Syntax
NET VIEW \\%PrintServer% 2>&1 | FIND /I "%PrintShare%" >NUL
IF ERRORLEVEL 1 GOTO Syntax

:: Check remote PC if specified
IF DEFINED RemotePC SET RemotePC=%RemotePC:\=%
IF DEFINED RemotePC (
      PING %RemotePC% -n 1 -w 1000 2>&1 | FIND "TTL=" >NUL
      IF ERRORLEVEL 1 GOTO Syntax
      SET RemotePC=/C\\%RemotePC%
)

:: Install the printer on the specified computer
RUNDLL32.EXE PRINTUI.DLL, PrintUIEntry /ga /n%Printer% %RemotePC%
IF NOT ERRORLEVEL 1 ECHO Printer installed, please reboot %RemotePC%

ENDLOCAL
GOTO:EOF

:Syntax
ECHO.
ECHO AddPrint.bat,  Version 1.01 for Windows 2000
ECHO Install a network printer on any PC on the network
ECHO.
ECHO Usage:  ADDPRINT  \\print_server\printer_share  [ remote_pc ]
ECHO.
ECHO Where:              "print_server"   is the print server name or IP address
ECHO                     "printer_share"  is the share name for the printer
ECHO                     "remote_pc"      is the PC that will be using the
ECHO                                      network printer -- default is local PC
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com

IF "%OS%"=="Windows_NT" ENDLOCAL

0
 
LVL 21

Expert Comment

by:mastoo
ID: 18774895
I like the AddPrint.bat file you posted a lot better than my one liner.  Doesn't it work?  What error do you get?
0
 

Author Comment

by:melvinsanders
ID: 18774934
Windows cannot access the specified  device, path, or file. you may not have the appropriate permissions to accesst the item. Try it
0
 
LVL 21

Accepted Solution

by:
mastoo earned 500 total points
ID: 18775216
How about delete the first line that turns the echo off.  Then when you run the script it will show each line as it executes, so you'll be able to see which line is giving the error.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

The use of stolen credentials is a hot commodity this year allowing threat actors to move laterally within the network in order to avoid breach detection.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now