Results 1 to 2 of 2

Thread: Network Printer Logon Script

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2009
    Posts
    1

    Network Printer Logon Script

    I'm running a Win2008 domain, and have a User-based logon GPO referencing a VB
    script which shares several network printers, each shared from a single file
    server. This GPO applies to "Domain Users." My issue is that if I delete a the shared printer off the GPO (and server too), it remains on the client workstations, confusing the end users. What's the best way to remove an old network printer from workstations?

    Here's the current logon script:

    MapPrinter "\\DC1\HPLJ2300N"
    MapPrinter "\\DC1\DELL1710N"
    MapPrinter "\\DC1\DELL3100CN"

    Sub MapPrinter(strPrinter)
    On Error Resume Next
    Set objNetwork = CreateObject("WScript.Network")
    boolConnected = False
    intAttempts = 1
    While boolConnected = False And intAttempts <= 10
    Err.Clear
    objNetwork.AddWindowsPrinterConnection strPrinter
    If Err.Number <> 0 Then
    intAttempts = intAttempts + 1
    WScript.Sleep 2000
    Else
    boolConnected = True
    End If
    Wend
    Err.Clear
    On Error GoTo 0
    End Sub

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Network Printer Logon Script

    Have you considered using the new Group Policy Client Side Extension Preferences in Server 2008? You can use them to map printers and if you tick the box that says "Remove when out of scope" or something like that then the printer will be deleted as soon as you change the GPO options so that they dont affect that user. One word of warning if you do go down this path though, to enable that option you have to set the creation mode to "Replace" which means that all printers mapped in this way will be recreated each time the user logs in, which can take some time if you have a lot of printers. The other downside to this is that it requires the client workstations be on XP SP2 and have a certain windows update installed, which isnt available in MSI format so you cant deploy it by group policy We just deployed it manually on a small site of 60 machines as we were migrating them all to a new domain anyway, but I can imagine it being a pain to do on a larger network.

    So, if you don't want to do things that way then you could just have another function in your script that deletes a printer. Then when you want to remove a printer you simply add a line to your script that deletes that particular printer, then after a while when you know all users that had that printer will have logged in, remove the line from the script. There isnt really a better way of doing it as far as I know (other than using the GPO method mentioned above).
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width