• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1078
  • Last Modified:

Computer Logon script to add multiple printers and set one as default

Here is my basic vbs script for adding these four network printers. The problem is users jump around so much that if one user logs on downstairs no matter what user it is need the same printer as default. How can I add this to my script. I need it to be scripts for computer not user and I will add them to group policy..will this script work for a computer logon script?

Set objWSHNetwork = CreateObject("WScript.Network")  'create network object
strConnectString = "\\server01\HP 4300N RICK AND JUDY OFFICE"
strResult = objWSHNetwork.AddWindowsPrinterConnection(strConnectString)

Set objWSHNetwork = CreateObject("WScript.Network")  'create network object
strConnectString = "\\server01\KM 4530 DOWNSTAIRS"
strResult = objWSHNetwork.AddWindowsPrinterConnection(strConnectString)

Set objWSHNetwork = CreateObject("WScript.Network")  'create network object
strConnectString = "\\server01\KM 5050 UPSTAIRS"
strResult = objWSHNetwork.AddWindowsPrinterConnection(strConnectString)

Set objWSHNetwork = CreateObject("WScript.Network")  'create network object
strConnectString = "\\server01\KM 4530 UPSTAIRS"
strResult = objWSHNetwork.AddWindowsPrinterConnection(strConnectString)
0
LeviDaily
Asked:
LeviDaily
  • 2
1 Solution
 
elissaqpCommented:
This is the script for setting a default printer:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = 'ScriptedPrinter'")
For Each objPrinter in colInstalledPrinters
    objPrinter.SetDefaultPrinter()
Next
0
 
elissaqpCommented:
or you can try:

Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"
WshNetwork.SetDefaultPrinter "\\PrintServer1\Xerox300"
0
 
LeviDailyAuthor Commented:
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"
WshNetwork.SetDefaultPrinter "\\PrintServer1\Xerox300"

That one worked! Anyone know if it will work for a computer logon script?
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now