techie211 Posted May 28, 2009 Posted May 28, 2009 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:confused: Also, should I be using a .bat instead? any help is appreciated. -j
kmount Posted May 28, 2009 Posted May 28, 2009 I'd think you'd want this as a login script rather than a start up script.
DrPerceptron Posted May 28, 2009 Posted May 28, 2009 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/download/8/2/c/82cffcfa-56f6-4fc3-bfa5-80cd84793871/PrintUIUsersGuide.doc [ Windows Server 2003: PrintUI.DLL User's Guide and Reference ]
sted Posted May 28, 2009 Posted May 28, 2009 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
Michael Posted May 28, 2009 Posted May 28, 2009 You can deploy by user or by machine using GPOs, or a combination of both
Windy08 Posted May 28, 2009 Posted May 28, 2009 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"
techie211 Posted June 2, 2009 Author Posted June 2, 2009 thanks for all the replies. the mapping still does not work:mad: 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:confused: Anyway, if anyone has any ideas I'd appreciate it.
MYK-IT Posted June 2, 2009 Posted June 2, 2009 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.
techie211 Posted June 8, 2009 Author Posted June 8, 2009 script still not working:doh: 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?
Gerry Posted June 8, 2009 Posted June 8, 2009 Here's a sample vbs of a script I use: 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.
Ric_ Posted June 8, 2009 Posted June 8, 2009 @techi211: Also check out http://www.edugeek.net/wiki/index.php/Printer_Addition_Based_on_Location
coomberoadtech Posted June 8, 2009 Posted June 8, 2009 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.
techie211 Posted June 8, 2009 Author Posted June 8, 2009 Here's a sample vbs of a script I use: 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?
AlexB Posted June 9, 2009 Posted June 9, 2009 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 ' 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
techie211 Posted June 9, 2009 Author Posted June 9, 2009 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:mad:
sted Posted June 9, 2009 Posted June 9, 2009 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:mad: as i suggested use the startup script to copy a shorcut to the printer script to c:\documetns and settings\all users\start menu\programs\startup that way every logon it runs it from the server
Gerry Posted June 12, 2009 Posted June 12, 2009 @techie211: Sorry for not replying sooner. The group policy is added to the Computer Configuration. Here it can take up to a few hours for the policy to become active, and as I mentioned our desktops won't install the drivers unless we log-in with an admin account first (we haven't figured out why yet-hoping Server 2008 will sort it out when we switch...) For the odd staff PC that isn't a member of the room's group in Active Directory, we add a shortcut to the script in All Users->Startup.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now