Solved

Setting up printer via scripts

Posted on 2007-03-22
9
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
A small collection of useful tips and tricks for Windows 10 users that I decided to write as a result of recent questions that were asked and answered at Experts Exchange. Two short video tutorials included. Enjoy..
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

707 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