+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
Windows Server 2000/2003 Thread, mapping printers via .vbs & GPO in Technical; hey ppl, I want to map two printers to one of our labs using .vbs and GPO. the print server ...
  1. #1
    techie211's Avatar
    Join Date
    Feb 2009
    Posts
    134
    Thank Post
    34
    Thanked 1 Time in 1 Post
    Rep Power
    0

    mapping printers via .vbs & GPO

    hey ppl, I want to map two printers to one of our labs using .vbs and GPO. the print server is located at same location. I want to apply it to the 'computer' so who ever logs on has access to those printers. Here is an example of the .vbs I'm using...
    ******************************************
    Option Explicit
    Dim objNetwork, strUNCPrinter1, strUNCPrinter2
    strUNCPrinter1 = "\\zara\HPLaserJ"
    strUNCPrinter2 = "\\zara\Epson"
    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.AddWindowsPrinterConnection strUNCPrinter1
    objNetwork.AddWindowsPrinterConnection strUNCPrinter2
    objNetwork.SetDefaultPrinter strUNCPrinter1

    WScript.Quit
    ******************************************

    when I run this script locally it works fine. When I add it to the OU policy's 'Startup' it does not work Also, should I be using a .bat instead? any help is appreciated.

    -j

  2. #2


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,690
    Thank Post
    352
    Thanked 795 Times in 714 Posts
    Rep Power
    346
    I'd think you'd want this as a login script rather than a start up script.

  3. #3
    DrPerceptron's Avatar
    Join Date
    Dec 2008
    Location
    In a house
    Posts
    922
    Thank Post
    34
    Thanked 134 Times in 114 Posts
    Rep Power
    41
    If you have Server 2003 R2, you can leverage that to deploy it.

    You could use printui.dll I think to add a printer per machine

    http://download.microsoft.com/downlo...UsersGuide.doc [ Windows Server 2003: PrintUI.DLL User's Guide and Reference ]

  4. #4


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,588
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296
    i use a startup script to copy a shortcut to the printer script to the %allusersprofile%\start menu\programs\startup that way every time anyone logs into that pc it runs the latest version of the vbs form the server

  5. #5

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,262
    Thank Post
    242
    Thanked 1,568 Times in 1,250 Posts
    Rep Power
    340
    You can deploy by user or by machine using GPOs, or a combination of both

  6. #6

    Join Date
    Mar 2008
    Location
    Doncaster
    Posts
    11
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    You have to set the loopback processing as well.
    Open the Group Policy Object editor (gpedit.msc) and go to the group policy you set for the script you are using.
    Expand the Computer Configuration node.
    Expand the Administrative Templates node.
    Expand the System node.
    Expand the Group Policy
    Locate the setting "User Group Policy loopback processing mode".
    Double click this setting.
    Set it to "Merge"

    Your Group Policy should now work

    If it still doesn't work, try putting your script in the "Logon" part of the OU instead of the "Startup"

  7. #7
    techie211's Avatar
    Join Date
    Feb 2009
    Posts
    134
    Thank Post
    34
    Thanked 1 Time in 1 Post
    Rep Power
    0
    thanks for all the replies. the mapping still does not work I've done a 'gpresult' on the workstation and it shows it's pulling from the correct GPO. I've done a gpupdate and reboot the workstation but the printers are not showing up in 'Printers and Faxes'. I've tried puting the .vbs in the 'Logon' and the 'Startup' with no success. But again if I run the same script locally the printers show up Anyway, if anyone has any ideas I'd appreciate it.

  8. #8

    Join Date
    Dec 2007
    Posts
    867
    Thank Post
    90
    Thanked 165 Times in 140 Posts
    Rep Power
    49
    I use a similiar setup / script.

    The script is added to the GPO that is assigned to the OU that the computer is contained within.

    User Configuration > Windows Settings > Scripts (Logon/Logoff)

    As mentioned, make sure that "Local Loopback" is enabled and set to "Merge"

    Also check the properties of the GPO to ensure that "Disable User Configuration Settings" is NOT enabled.

    Failing that check the permissions of the printer, and possibly check restrictions of other GPOs that are applied to users / students. May find that "run command" is disabled that would stop .bat files unless the option is enabled to allow this during logon.

  9. #9
    techie211's Avatar
    Join Date
    Feb 2009
    Posts
    134
    Thank Post
    34
    Thanked 1 Time in 1 Post
    Rep Power
    0
    script still not working Loopback is enabled and set to 'Merge' and I tried putting the script in both
    "Logon" and "Startup" part of the OU. Printer permissions are set to Everyone/Full and I even threw the
    user group in. I also added that user group into the local Administrator group of each workstation but still
    nothing. What am I missing? should I do away with the .vbs and try .bat?

  10. #10
    Gerry's Avatar
    Join Date
    Jun 2007
    Location
    North Wales
    Posts
    431
    Thank Post
    60
    Thanked 38 Times in 35 Posts
    Rep Power
    24
    Here's a sample vbs of a script I use:
    Code:
    Set wshNetwork = CreateObject("WScript.Network")
    on Error Resume Next
    
    Printer1="\\printserver\printer_name"
    
    'Deletes all network printers
    Set clPrinters = WshNetwork.EnumPrinterConnections
    On Error Resume Next
    For i = 0 to clPrinters.Count - 1 Step 2
    wshNetwork.RemovePrinterConnection clPrinters.Item(i+1), true
    Next
    
    'Sets up printers
    WshNetwork.AddWindowsPrinterConnection Printer1
    WshNetwork.SetDefaultPrinter Printer1
    It's saved to the "netlogon" folder.

    In the GPO it's added into "Administrative Templates->System->Logon->Run these programs at user logon".

    If your script isn't working, try manually running it after logging-in. Here we have a problem in that we have to log-in as an admin if the printer driver hasn't been installed yet.

  11. #11

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,593
    Thank Post
    109
    Thanked 764 Times in 595 Posts
    Rep Power
    181

  12. #12
    coomberoadtech's Avatar
    Join Date
    Jun 2009
    Location
    Brighton
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I use an environment variable to set the location of each computer, i apply that using policy make to add the reg entry for the environment variable to each OU in which i put the computers in each location. you can add an environment variable at HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. i call mine location and then give each location a number.
    then in my logon scripts i poll for the location number using an IF statement like this:
    if env("location") = "1" then
    objNetwork.AddWindowsPrinterConnection "\\server\printer1"
    objNetwork.SetDefaultPrinter "\\server\printer1"

    objNetwork.AddWindowsPrinterConnection "\\server\printer2"

    elseif env("location") = "2" then ...
    and so on.
    id say thats a pretty easy and fool proof way to do it.
    anyways im new to this forum but i hope that helps in some small way.

  13. #13
    techie211's Avatar
    Join Date
    Feb 2009
    Posts
    134
    Thank Post
    34
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Quote Originally Posted by Gerry View Post
    Here's a sample vbs of a script I use:
    Code:
    Set wshNetwork = CreateObject("WScript.Network")
    on Error Resume Next
    
    Printer1="\\printserver\printer_name"
    
    'Deletes all network printers
    Set clPrinters = WshNetwork.EnumPrinterConnections
    On Error Resume Next
    For i = 0 to clPrinters.Count - 1 Step 2
    wshNetwork.RemovePrinterConnection clPrinters.Item(i+1), true
    Next
    
    'Sets up printers
    WshNetwork.AddWindowsPrinterConnection Printer1
    WshNetwork.SetDefaultPrinter Printer1
    It's saved to the "netlogon" folder.

    In the GPO it's added into "Administrative Templates->System->Logon->Run these programs at user logon".

    If your script isn't working, try manually running it after logging-in. Here we have a problem in that we have to log-in as an admin if the printer driver hasn't been installed yet.
    Gerry, do I set the bold line above in the 'Computer' config or 'User' config? also, how long does it take the workstation to pull the script off it's DC?

  14. #14
    AlexB's Avatar
    Join Date
    Jul 2006
    Location
    Warwickshire
    Posts
    365
    Thank Post
    36
    Thanked 36 Times in 32 Posts
    Rep Power
    23
    Slightly off topic, but you might want to check this script I found a while back (author in script comments). It allows printer allocation based off the beginning of the computer name. So if you have 6A-01, 6A-02, etc where 6A is the room name then all computers in that room get the printers specified

    Code:
    ' Script to add network printers to workstations and thin clients
    ' Author: Ric Charlton 
    ' Declare variables and enumerate existing printer connections
     
    On Error Resume Next
    
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set oPrinters = WshNetwork.EnumPrinterConnections
     
    Dim computerName
    computerName = LCase(WshNetwork.ComputerName)
     
    ' Delete existing connections to network printers
    For i = 0 to oPrinters.Count - 1 Step 2
            On Error Resume Next
    	    if Left(oPrinters.Item(i), 2) = "\\" then
              	WshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true
            end if
    Next
     
     
    ' Not used by me, but I left in here incase for others
    ' Change "svrts" to the name of name thin client server so that the script uses the thin client name
    ' instead of the server's
    ' Citrix specific section
    if (Left(computerName, 5) = "svrts") then
    	computerName = LCase(WshShell.ExpandEnvironmentStrings("%CLIENTNAME%"))
    end if
    
    ' Add printer connections dependant upon location
    ' Variable to select print server
    Dim printServer
    printServer = "theta"
    
    ' These mount for all machines
    WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\PrinterA3"
    WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\Printer8"
    
    Select Case (Left(computerName, 3))
    
    	Case "6a-"
    		WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\Printer5"
    		WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\Printer7"
    		WshNetwork.SetDefaultPrinter "\\" & printServer & "\Printer5"
    		
    	Case "06-"
    		WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\Printer3"
    		WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\Printer4"
    		WshNetwork.SetDefaultPrinter "\\" & printServer & "\Printer3"
    
    	Case "lib"
    		WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\Printer1"
    		WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\Printer2"
    		WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\Printer3"
    		WshNetwork.SetDefaultPrinter "\\" & printServer & "\Printer1"
    	
    End Select
    
     ' This lets you pick of specific full computer names where they don't fit into the scheme above
    Select Case (computerName)
     
    	Case "np000e7bd5a561"
    		WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\\Printer1"
    		WshNetwork.AddWindowsPrinterConnection "\\" & printServer & "\\Printer2"
    		WshNetwork.SetDefaultPrinter "\\" & printServer & "\\Printer3"
     
     
    End Select

  15. #15
    techie211's Avatar
    Join Date
    Feb 2009
    Posts
    134
    Thank Post
    34
    Thanked 1 Time in 1 Post
    Rep Power
    0
    thanks all, the scripts I have and the scripts that were posted here all work if I run them locally. My problem is the workstations are not pulling down scripts. I've checked permissions on the printers, I've tried different types of scripts .vbs, .bat, which all work if run locally btw. I have 'Loopback processing mode' enabled. I've tried adding the scripts in the 'Startup' and 'Logon'. I've tried what 'Gerry' suggested.
    what I've done for now since I have folder redirect is I created a 'printer' folder in the labs Start/Programs and added the printer's shortcut in that folder. Once the user logs on they double click the printer and it installs it into the 'Printers and Faxes'. I would still like to know why a simple task like mapping printers seems so complicated

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 23
    Last Post: 13th November 2013, 01:29 PM
  2. Citrix not mapping client printers
    By Andi in forum Thin Client and Virtual Machines
    Replies: 0
    Last Post: 7th November 2008, 12:02 PM
  3. Replies: 6
    Last Post: 7th April 2008, 07:10 PM
  4. Mapping Printers based on Location
    By NeoNemesis in forum Windows
    Replies: 11
    Last Post: 6th August 2007, 08:03 AM
  5. Home drive not mapping when moving to VBS
    By mullet_man in forum Windows
    Replies: 6
    Last Post: 17th June 2007, 02:16 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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