buzzard Posted May 10, 2010 Posted May 10, 2010 Hi, I've a rather frustrating problem as I'm no coding expert, i've the below vbs script that assigns printers and sets default based on OU, it's come from this valuble community in the first place and with some slight tweaking works a treat for us, the issue is that the centre manager now doesn't want student access to the colour laser, nice and easy, set deny on the printer ACL for students. Job done, however as this confuses them the colour printer is not to be on for students, just staff. Is there a way to incorporate this change into the script? maybe a 'are they a member of staff group?' type affair? I'd apreciate any help or pointers the assist in arriving at a solution! dim oAdSysInfo, sCompPath set WShShell = WScript.CreateObject("WScript.Shell") set WShNetwork = WScript.CreateObject("WScript.Network") set oAdSysInfo = CreateObject("AdSystemInfo") Set oPrinters = WshNetwork.EnumPrinterConnections ' Delete existing connections to network printers For i = 0 to oPrinters.Count - 1 Step 2 On Error Resume Next if Left(oPrinters.Item(i), 3) <> "lpt" And Left(oPrinters.Item(i), 3) <> "usb" And Left(oPrinters.Item(i), 2) <> "HP" then WshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true else WScript.Echo "No network printers found" end if Next ' Get the Computer Name sCompPath = oAdSysInfo.ComputerName ' Set the printer dependant on the OU name for the PC if InStr (1, sCompPath, "OU=admincomputers", 1) then WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-CLZR-5250N" WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-MFD-W2330" elseif InStr(1, SCompPath, "OU=laptops", 1) then WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-CLZR-5250N" WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-MFD-W2330" WShNetwork.SetDefaultPrinter "\\1115-dc-004\LCH-MFD-W2330" elseif InStr(1, SCompPath, "OU=room1", 1) then WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-CLZR-5250N" WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-MFD-W2330" WShNetwork.SetDefaultPrinter "\\1115-dc-004\LCH-MFD-W2330" elseif InStr(1, SCompPath, "OU=room2", 1) then WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-CLZR-5250N" WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-MFD-W2330" WShNetwork.SetDefaultPrinter "\\1115-dc-004\LCH-MFD-W2330" elseif InStr(1, SCompPath, "OU=staffroom", 1) then WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-CLZR-5250N" WShNetwork.AddWindowsPrinterConnection "\\1115-dc-004\LCH-MFD-W2330" WShNetwork.SetDefaultPrinter "\\1115-dc-004\LCH-MFD-W2330" else WScript.Echo "A default printer has not been assigned. Please contact ICT support via the helpdesk so that the problem can be resolved" end if Thanks for looking, now back to trying to code!! Ben
buzzard Posted May 10, 2010 Author Posted May 10, 2010 [noob]OK so i'd set deny on the wrong printer!! it became obvious after testing it properly! the deny stops the printer from being mapped so solves the problem [/noob]
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