Solved

Setting up printer via scripts

Posted on 2007-03-22
9
178 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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
 

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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

726 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