Announcement

Collapse
No announcement yet.

Need help writing script to Add Printer

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help writing script to Add Printer

    I am currently running Windows Server 2003 with Active Directory Environment.

    This is for a school ... and I have a Media Lab, and the HS Library. All the computers in the media lab are assigned to the "Media Lab" group and all the computers in the Library are assigned to the group "HS Library". I have not been able to figure out a way to script it so that when a user loggs in to the media lab all that is added is the media lab printer and when they logg into the library all that is added is the hs library printer. So pretty much printers are added according to what computer they are logged into.

    Thanks in advance for your help!

  • #2
    Re: Need help writing script to Add Printer

    This should do,

    First download IFmember, and place the EXE in your netlogon directory of your DC's.

    http://www.microsoft.com/windows2000...ifmember-o.asp

    Then use this in your logon script.

    Code:
    Set WshNetwork = CreateObject("WScript.Network")
    Set objShell = CreateObject("Wscript.Shell")
    
    WSHNetwork.MapNetworkDrive "Y:", "\\DC\Netlogon"
    
    WshNetwork.RemovePrinterConnection "\\PrintServer\HSLibPrinter"
    WshNetwork.RemovePrinterConnection "\\PrintServer\MediaLabPrinter"
    
    strCommand = "%comspec% /c Y:\IfMember.exe HSLibrary"
    
    intReturn = objShell.Run(strCommand, 2, True)
    If intReturn = 1 Then
    WshNetwork.AddWindowsPrinterConnection "\\PrintServer\HSLibPrinter"
    WshNetwork.SetDefaultPrinter "\\PrintServer\HSLibPrinter"
    End If
    
    strCommand = "%comspec% /c Y:\IfMember.exe MediaLab"
    
    intReturn = objShell.Run(strCommand, 2, True)
    If intReturn = 1 Then
    WshNetwork.AddWindowsPrinterConnection "\\PrintServer\MediaLabPrinter"
    WshNetwork.SetDefaultPrinter "\\PrintServer\MediaLabPrinter"
    End If
    
    WshNetwork.RemoveNetworkDrive "Y:"
    topper
    * Shamelessly mentioning "Don't forget to add reputation!"

    Comment

    Working...
    X