Solved

Network Printer Connection At Logon

Posted on 2004-09-08
20
295 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
  • 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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 125 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

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

Let’s list some of the technologies that enable smooth teleworking. 
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

856 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