Solved

Network Printer Connection At Logon

Posted on 2004-09-08
20
288 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
Comment Utility
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
Comment Utility
It gives me a runtime error. error code is 800A0046.
0
 
LVL 15

Expert Comment

by:Yan_west
Comment Utility
0
 

Author Comment

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

Expert Comment

by:Yan_west
Comment Utility
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
Comment Utility
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
Comment Utility
I believe this document has exactly what you are looking for:
http://support.microsoft.com/?kbid=181663
0
 
LVL 3

Expert Comment

by:frieked
Comment Utility
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:cembi
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This is an article about my experiences with remote access to my clients (so that I may serve them) and eventually to my home office system via Radmin Remote Control. I have been using remote access for over 10 years and have been improving my metho…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now