?
Solved

Network Printer Connection At Logon

Posted on 2004-09-08
20
Medium Priority
?
298 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:cembi
[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
  • 6
  • 4
  • 4
  • +1
20 Comments
 
LVL 15

Expert Comment

by:Yan_west
ID: 12009090
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
 

Author Comment

by:cembi
ID: 12009406
It gives me a runtime error. error code is 800A0046.
0
 
LVL 15

Expert Comment

by:Yan_west
ID: 12009424
0
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 

Author Comment

by:cembi
ID: 12009492
Permissions are not an issue here. I am admnistrator unless you are talking about other permissions.
0
 
LVL 15

Expert Comment

by:Yan_west
ID: 12009594
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
 
LVL 15

Expert Comment

by:Yan_west
ID: 12009643
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
 
LVL 3

Expert Comment

by:frieked
ID: 12009767
I believe this document has exactly what you are looking for:
http://support.microsoft.com/?kbid=181663
0
 
LVL 3

Expert Comment

by:frieked
ID: 12009777
0
 

Author Comment

by:cembi
ID: 12011106
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
 
LVL 3

Expert Comment

by:frieked
ID: 12011361
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
 
LVL 1

Expert Comment

by:duraisamy
ID: 12014590
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
 

Author Comment

by:cembi
ID: 12016550
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
 
LVL 1

Expert Comment

by:duraisamy
ID: 12017274
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
 

Author Comment

by:cembi
ID: 12017478
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
 
LVL 1

Expert Comment

by:duraisamy
ID: 12017702
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
 

Author Comment

by:cembi
ID: 12020767
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
 
LVL 1

Accepted Solution

by:
duraisamy earned 500 total points
ID: 12024408
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

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

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

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
Make the most of your online learning experience.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

762 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