Solved

Deploying Printers without Server 2003 R2

Posted on 2007-11-21
9
407 Views
Last Modified: 2010-03-17
We are redoing the printers at my location (400+ people) and I am having a hard time figuring out how to push them out to the users without having to sit down at each PC and setup the Printing Preferences for each user.

I set the printing preferences on the server for the specific printer but the preferences don't "roll down" to the user when the printer is mapped.  I called support on this issue and they stated that this was not possible.

My question is the following:  How do I roll out printers to a group of users with certain preferences set without Server 2003 R2?
0
Comment
Question by:fowen
  • 5
  • 2
9 Comments
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, I'm not really sure if this would do what you need, but, as a test, just remove the current printer connection, then re-add it, and if that works to "reset" the user preferences, then the following script does the same thing, removing a printer, then re-adding it.

I actually use this script to migrate server printers, but you can use for the same printer, just put the same printer path in arrPrinterShares, with the "old" and the "new being the same printer, separated by a colon symbol ( : ).

It also logs the actions to a file specified by this line:
strLogFile = "\\Ntfp\userlogins$\mccdc07_printer_changes\" & objNetwork.UserName & ".txt"

'========================
arrPrinterShares = Array( _
      "\\MCCDC07\CroydonCivic_LocalLaws1:\\MCCFSCROY\CroydonCivic_NeighborhoodServices1", _
      "\\MCCDC07\By_Laws_2300LH:\\MCCFSCROY\CroydonCivic_NeighborhoodServices1", _
      "\\MCCDC07\By_Laws_2300:\\MCCFSCROY\CroydonCivic_NeighborhoodServices1", _
      "\\MCCDC07\CroydonCivic_NeighborhoodServices1:\\MCCFSCROY\CroydonCivic_NeighborhoodServices1", _
      "\\MCCDC07\Leisure lj2430:\\MCCFSCROY\CroydonLeisure_LeisureFacilities", _
      "\\MCCDC07\Rates printer LJ 8150:\\MCCFSCROY\CroydonCivic_Rates1", _
      "\\MCCDC07\CroydonCivic_Rates1:\\MCCFSCROY\CroydonCivic_Rates1", _
      "\\MCCDC07\CroydonCivic_Waste:\\MCCFSCROY\CroydonCivic_Waste", _
      "\\MCCDC07\HP LaserJet 2100 PCL6:\\MCCFSCROY\CroydonCivic_CustomerService2", _
      "\\MCCDC07\CroydonCivic_CustomerService2:\\MCCFSCROY\CroydonCivic_CustomerService2", _
      "\\MCCDC07\HP LaserJet 2430 PCL 6:\\MCCFSCROY\CroydonCivic_Health1", _
      "\\MCCDC07\CroydonCivic_Health1:\\MCCFSCROY\CroydonCivic_Health1", _
      "\\MCCDC07\CroydonCivic_CustomerService1:\\MCCFSCROY\CroydonCivic_CustomerService1", _
      "\\MCCDC07\Croydon Civic Cust service 2300:\\MCCFSCROY\CroydonCivic_CustomerService1", _
      "\\MCCDC07\CroydonCivic_NeighborhoodServices2:\\MCCFSCROY\CroydonCivic_NeighborhoodServices2", _
      "\\MCCDC07\FX Document Centre C360 PCL 6:\\MCCFSCROY\CroydonCivic_FX_Document_Centre_C360", _
      "\\MCCDC07\FX DocuCentre-II C3000 PCL 6:\\MCCFSCROY\CroydonLeisure_FX_DocuCentre_II_C3000", _
      "\\MCCDC07\CroydonCivic_ FXDocumentCentre:\\MCCFSCROY\CroydonLeisure_FX_DocuCentre_II_C3000" _
      )

Set objNetwork = CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where Local = False")

strLogFile = "\\Ntfp\userlogins$\mccdc07_printer_changes\" & objNetwork.UserName & ".txt"
Set objOutputFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
objOutputFile.WriteLine "Logged in at: " & Now & " on " & objNetwork.ComputerName
      
On Error Resume Next
If colPrinters.Count <> 0 Then
    For Each objPrinter In colPrinters
            For intPrinter = LBound(arrPrinterShares) To UBound(arrPrinterShares)
                  strOldPrinter = Split(arrPrinterShares(intPrinter), ":")(0)
                  strNewPrinter = Split(arrPrinterShares(intPrinter), ":")(1)
                  boolManual = False
                  If Left(strOldPrinter, 7) = "MANUAL=" Then
                        boolManual = True
                        strOldPrinter = Replace(strOldPrinter, "MANUAL=", "")
                  End If
                  If UCase(objPrinter.DeviceID) = UCase(strOldPrinter) Then
                        If boolManual = True Then
                              objOutputFile.WriteLine "MANUAL: Please obtain the account code for the printing from " & objPrinter.DeviceID & " and then replace that with " & strNewPrinter & " and set the account code."
                        ElseIf objPrinter.Default = True Then
                              objNetwork.RemovePrinterConnection objPrinter.DeviceID, True, True
                              objNetwork.AddWindowsPrinterConnection strNewPrinter
                              objNetwork.SetDefaultPrinter strNewPrinter
                              objOutputFile.WriteLine "Replaced " & objPrinter.DeviceID & " with " & strNewPrinter & " and set it as default"
                        Else
                              objNetwork.RemovePrinterConnection objPrinter.DeviceID, True, True
                              objNetwork.AddWindowsPrinterConnection strNewPrinter
                              objOutputFile.WriteLine "Replaced " & objPrinter.DeviceID & " with " & strNewPrinter
                        End If                              
                  End If
            Next
            If Err.Number <> 0 Then
                  objOutputFile.WriteLine Err.Number & ": " & Err.Description & VbCrLf & objPrinter.DeviceID & " --> " & strNewPrinter
                  Err.Clear
            End If
    Next
End If
Err.Clear
On Error GoTo 0

objOutputFile.Close
Set objOutputFile = Nothing
'========================

I hope that suits your needs.  After today, I won't be available, so hopefully we can sort it out for you.

Regards,

Rob.
0
 

Author Comment

by:fowen
Comment Utility
I am not sure if that will work for me or not.

What I need to do is roll out two specific printers to a specific group of OU's and I would also like to delete any network printers that are currently mapped to those machines.

I have figured out the Printing Preferences issue.  I just need to get these printers mapped without having to walk around to each desk.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
OK, no problem, so to get the printers mapped, just use:

Set objNetwork = CreateObject("WScript.Network")
strNewPrinter = "\\server\printershare"
objNetwork.AddWindowsPrinterConnection "\\server\printer1"
objNetwork.AddWindowsPrinterConnection "\\server\printer2"
objNetwork.SetDefaultPrinter "\\server\printer1"

Regards,

Rob.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Sorry, ignore that strNewPrinter = "\\server\printershare" line, you won't need that if you specify the share path after AddWindowsPrinterConnection....

Regards,

Rob.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:fowen
Comment Utility
Will that work in a normal login script?  I think it is a WMI code, but I have never used WMI.

Would this add a machine based printer or a user based printer?

Also, if I wanted to remove all network printers (user AND machine based) do I need to know those names?  How do I go about doing that?

Thank you for your help!
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
It should work in a normal VBS logon script, provided that WSH is running on the client machines.

Also, the MapNetworkPrinterConnection method will only apply to each user that runs the script, but as long as you run it via AD under a User Configuration Logon Script it will apply to each user anyway.

Also see this for removing all network printers:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov07/hey1102.mspx

With a logon script though, removing "machine based" printers would be difficult because I'm not sure the code in the above article would be able to enumerate those, but you can try
   Where Local = True")
instead of
   Where Network = True")

Regards,

Rob.
0
 
LVL 12

Expert Comment

by:benhanson
Comment Utility
Just so you know, the print server doesn't have to be R2.  If you have any R2 servers in your organization you can do this.  It's basically a schema extension in Active directory, an ADM file and a logon script.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
fowen, did you make any progress on this?

Regards,

Rob.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Mapping Drives using Group policy preferences Are you still using old scripts to map your network drives if so this article will show you how to get away for old scripts and move toward Group Policy Preference for mapping them. First things f…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now