Network Printer Connection At Logon

Is there a way to include network printer installation into a login script ? I have Windows 2003 Server and have 5 networked printers installed in it. Clients run WinNT4, 2000, XP. How can I add a line into login script that would automatically install the printers.
Thank you.
cembiIT Asked:
Who is Participating?
 
duraisamyConnect With a Mentor Commented:
Dear rubens,
Try This......

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\server\printer1")
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where DriverName = 'HP LaserJet'")
For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
Next


Durai
0
 
Yan_westCommented:
Use this script:

This works great on Windows 2K and XP machines. It will probably work on W9x machines as well.

Copy & paste the following into a text editor and save with a .vbs extension.

'// Name: setprint.vbs
'// Description: Add a network printer and make it the default

Set WshNetwork = CreateObject("WScript.Network")

'// Adds the printer. Substitute your server name and printer share.
WshNetwork.AddwindowsPrinterConnection "\\Server\printer"

'// Makes the specified printer the default.
WshNetwork.SetDefaultPrinter "\\Server\printer"
0
 
cembiIT Author Commented:
It gives me a runtime error. error code is 800A0046.
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
Yan_westCommented:
0
 
cembiIT Author Commented:
Permissions are not an issue here. I am admnistrator unless you are talking about other permissions.
0
 
Yan_westCommented:
Hmm, this message is supposed to appear when the user does not have the permission to create the printer object.. like in the link I pointed you to, at the botton of the page. This is a permission problem for sure.. Can't get my finger on it yet..
0
 
Yan_westCommented:
check this solution, browse through it... We are using the script I gave you with no problem at all, so I have no idea why It would do that..


http://www.experts-exchange.com/Security/Win_Security/Q_20989261.html
0
 
friekedCommented:
I believe this document has exactly what you are looking for:
http://support.microsoft.com/?kbid=181663
0
 
friekedCommented:
0
 
cembiIT Author Commented:
This tool seems to be applicable for Windows NT only. I mentioned that I have Windows 2000 Pro as well Windows XP in the network.
0
 
friekedCommented:
It was originally introduced in windows nt but trust me, it works for both win2k and winXP... as well as 98 and me if you still use those.

you can always map printers with the following: "net use \\server\printersharename"

Make sure you have the drivers installed on the server for all OS's that you wish to use the printers on.
0
 
duraisamyCommented:
Hi,
I hope this will solve your problem.

copy the following code to notepad and save as .vbs extension.(printer.vbs)

Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\server\printer2"
WshNetwork.SetDefaultPrinter "\\server\printer2"

Copy the vbs file to server share folder.

then you can add the following line to your logon script bat file.

copy \\server\share\printer.vbs c:\
cscript printer.vbs
del c:\printer.vbs

Save and try it.

The script should be copied localy.

Regards,
Durai
0
 
cembiIT Author Commented:
Thanks Durai,
The vbs seems to be working when executed locally. However, I would like to have it included into a login script so it executes automatically. The way you reccomend it does not seem to execute. It only copies it locally onto C: drive. How do I get it to execute at login ?
Thank you,
Rubens
0
 
duraisamyCommented:
Hi Rubens,
I think you have problem to locate the exe while login.

Try this with your login script.

copy \\server\share\printer.vbs c:\
c:\windows\system32\cscript.exe printer.vbs
del c:\printer.vbs

Try this.

Durai
0
 
cembiIT Author Commented:
It is not working again. It copies it into local C: drive and that's it. Is there a way to automatically put it into Startup folder for all users ?
Thanks
0
 
duraisamyCommented:
Hi Rubens,


Try this.. this will work 100%.

It is working for me.

copy \\server\share\printer.vbs c:\
c:\windows\system32\cscript.exe c:\printer.vbs
del c:\printer.vbs
0
 
cembiIT Author Commented:
duraisamy,
Your solution seems to be working for me. One last thing. How would I delete printers through same .vbs script.
Thanks a lot,
Rubens
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.