Link to home
Start Free TrialLog in
Avatar of microsymplex
microsymplex

asked on

Moving print server, need to figure out how to map printers using a script.

Thanks in advance for all your help. You guys are great. I know nothing about creating a script but we are moving the print server to another device. Currently the printers are listed in a directory. I would like to map all the printers using a script. In the AD logon script, there is a logon.cmd and in it points to a vbs of set drives. Can I also add a command to set printers and if so what would the script be.

For example all printers will be on \\server1\      
ASKER CERTIFIED SOLUTION
Avatar of jkarnes12
jkarnes12
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This could possibly be a solution for you:

http://www.petri.co.il/changeprintsrv.htm
Avatar of microsymplex
microsymplex

ASKER

After looking at how the printers were setup, it looks like I will have to manually add each printer to the new print server then add a script to mapp all the printers for everyone.
Correct, as the 1st step you have to add and share printers on the new server (let say \\PRINTServer1) and install printer drivers on this server. Suggest you name printers the same as it were named on the old print server (so the users won't be too confused by migration).

2nd step - you arrange login script to add this shared printer when the user logins to network.

I found that con2prt.exe utility (http://www.paulmcgrath.net/download.php?list.2) is very handy in login scripts. It can flush all the shared printers (con2prt.exe /f) and add another printers from the list.

The example is below (\\%LOGONSERVER%\Scripts$\PRINT\ is the folder where I saved con2prt.exe program and MyPrinters.lst):

\\%LOGONSERVER%\Scripts$\PRINT\con2prt.exe /f
for /f %%i in (\\%LOGONSERVER%\Scripts$\PRINT\MyPrinters.lst) do \\%LOGONSERVER%\Scripts$\PRINT\con2prt.exe /c %%i

MyPrinters.lst contains this lines:
\\PRINTServer1\HP9001
\\PRINTServer1\HP9002
\\PRINTServer1\HP9003

I hope it will help.
Avatar of rhinoceros
For network printer mapping

(Logon.cmd example)

On error resume next
Set net = CreateObject("WScript.Network")
' Add new network printer
net.AddWindowsPrinterConnection "\\server1\HPLJ123"
net.AddWindowsPrinterConnection "\\server1\HPLJ890"

' Set default printer
net.SetDefaultPrinter "\\server1\HPLJ123"

'Also remove old printer link from users' profile
net.RemovePrinterConnection "\\server1\HPLJZZZ"


I hope it can help !
Sorry ! it is "logon.vbs" not "logon.cmd"
(Logon.cmd)
echo off
...
logon.vbs
...


(Logon.vbs)
On error resume next
Set net = CreateObject("WScript.Network")
' Add new network printer
net.AddWindowsPrinterConnection "\\server1\HPLJ123"
net.AddWindowsPrinterConnection "\\server1\HPLJ890"

' Set default printer
net.SetDefaultPrinter "\\server1\HPLJ123"

'Also remove old printer link from users' profile
net.RemovePrinterConnection "\\server1\HPLJZZZ"


***  It will call logon.vbs when you run logon.cmd on AD logon script

Sorry to say rhinoceros, but command processor is not Windows Explorer so logon.cmd won't call logon.vbs directly.
Why not... it is not physically run on Windows Explorer... now placed to AD logon script.

I always do it by .bat or .cmd extension file to call .vbs file. It's worked.

Have you tried it ?
You can create these 2 files on your local C: drive, and try to run it....

(logon.cmd)
hello.vbs
pause

(hello.vbs)
wscript.echo "Hello !"

What's result ?
Yes, on my XP home SP3 it works but it doesn't mean it is going to work on other Windows systems (as you can see they were not specified in the question) loging in to domain. Here is what Microsoft suggest how to run scripts from the Command Prompt: http://msdn.microsoft.com/en-us/library/ey73d9d3(VS.85).aspx
Friend, we are able to use this method on almost windows systems -  Windows XP, 2000, 2003, and Vista... Have you also already tried it on those all Windows systems as you said ?

What's Microsoft suggest ? Do you think Microsoft must have the absolute answer ? The important is that it's work or not.

In the world, nobody can say that "it's absolute answer, no choice"... include Bill Gxxx, rite ?
Perhaps you are right and it will work on most of the Windows versions. But if you look under the "hood" you will see that Windows Explorer is doing it exactly per Microsoft documentation (see screen-shot). Rather than rely on Windows Explorer configuration (which might be changed by firm policies or screwed by the users) I prefer to do it straight.

But this is probably irrelevant to the original question. I have posted the script which is working in my office, you did for your office. It is up to microsymplex to choose what he feels the best way to go.

Clipboard01.jpg