+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, Another Printer logon script! Needing Help in Coding and Web Development; Hi, I've a rather frustrating problem as I'm no coding expert, i've the below vbs script that assigns printers and ...
  1. #1
    buzzard's Avatar
    Join Date
    May 2006
    Location
    North West
    Posts
    303
    Thank Post
    105
    Thanked 27 Times in 23 Posts
    Rep Power
    24

    Another Printer logon script! Needing Help

    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!

    Code:
    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

  2. #2
    buzzard's Avatar
    Join Date
    May 2006
    Location
    North West
    Posts
    303
    Thank Post
    105
    Thanked 27 Times in 23 Posts
    Rep Power
    24
    [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]

  3. #3

    Join Date
    May 2010
    Location
    Romania
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    good you solved the problem

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 8
    Last Post: 25th February 2009, 09:50 AM
  2. Sorry Logon Printer Script.... again
    By DSapseid in forum Scripts
    Replies: 3
    Last Post: 23rd September 2008, 11:26 PM
  3. Replies: 13
    Last Post: 20th February 2008, 04:29 PM
  4. logon script for printer
    By ozzy in forum Scripts
    Replies: 6
    Last Post: 22nd November 2007, 03:03 PM
  5. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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