Poll: Was this script helpful?

Be advised that this is a public poll: other users can see the choice(s) you selected.

+ Post New Thread
Page 11 of 11 FirstFirst ... 7891011
Results 151 to 165 of 165
Scripts Thread, A Printer Script in Coding and Web Development; I wouldn't have thought you'd even need the bat. You can probably just add the command straight into the policy: ...
  1. #151
    meastaugh1's Avatar
    Join Date
    Jul 2006
    Location
    London/Hertfordshire
    Posts
    890
    Thank Post
    69
    Thanked 85 Times in 70 Posts
    Rep Power
    32

    Re: A Printer Script

    I wouldn't have thought you'd even need the bat. You can probably just add the command straight into the policy:

    Script name: c:\windows\system32\rundll32.exe
    Script parameters: c:\windows\system32\printui.dll,PrintUIEntry /ga /n\\printers\%printername%

    Haven't tested it, but you can give it a go when you get back.

  2. #152

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,834
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444

    Re: A Printer Script

    Sorry to act thick, but how do you mean?

    Z

  3. #153
    meastaugh1's Avatar
    Join Date
    Jul 2006
    Location
    London/Hertfordshire
    Posts
    890
    Thank Post
    69
    Thanked 85 Times in 70 Posts
    Rep Power
    32

    Re: A Printer Script

    If you're running a startup script, presumably you'd be executing it through GPO. In that case, where you'd specify the .bat file in the startup script section of the GPO, you can just specify the above instead, thereby negating the need for a batch file.

    Not particularly significant either way though.

  4. #154

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,834
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444

    Re: A Printer Script

    Ah right, thanks

    Z

  5. #155

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,037
    Thank Post
    209
    Thanked 425 Times in 306 Posts
    Rep Power
    144

    Re: A Printer Script

    Word of caution on adding printers with printUI;

    I've got into very messy situations using the printUI method of adding printers. Mainly because they can only be removed using the same command, so if you move machines to different areas of the school or rename your printers, you need to write a remove command for them first, then re-run the add command. Also I seem to recall running it more than once will result in the same printer being added multiple times, so be very careful if you set it as a startup script that it only gets run once!

    Is there any particular reason they can't be added via a logon script, as this is mine and most others prefered method?

    Mike.

  6. #156

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,834
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444

    Re: A Printer Script

    s there any particular reason they can't be added via a logon script, as this is mine and most others prefered method?
    Because it will be only used on some machines not all, if it is added to a logon script for all users if they log onto a computer without the printers on that machine having them in the script it will delete all the printers but not put any new ones on.

    Does that make sense?

    Z

  7. #157

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,037
    Thank Post
    209
    Thanked 425 Times in 306 Posts
    Rep Power
    144

    Re: A Printer Script

    If you make the delete printer connections line only run for the necessary machines like the add lines do, then all machines will run the script but machines that do meet the criteria will do nothing therefore leaving any existing printer connections intact.

    I'm just sure you will run into problems adding printers with the printUI command, and it can be a PITA to sort out if you do (trust me, I've been there!) If you do go down the route of using it, try it out throughly on one machine first before you unlesh it on your network.

    Mike.

  8. #158

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,834
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444

    Re: A Printer Script

    I will be using the VBS script i think.

    How do i get it to work on certain machines?

  9. #159

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,037
    Thank Post
    209
    Thanked 425 Times in 306 Posts
    Rep Power
    144

    Re: A Printer Script

    Looking at the script you're using on the previous page, it would make it a bit messy, owing to the loop technique used to remove all the network printers (I think there is a slightly shorter method of doing this, but it escapes me at the moment)

    All you need to do it remove the single instance of the 'remove printer connections' loop at the beginning of the script, and place a copy of it under each 'case' statement. this would ensure it only removes printer connections on machines where it's going to add them again. It will make the script a bit longer, but it will work just fine.

    Mike.

  10. #160

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,834
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444

    Re: A Printer Script

    well i will look into that if the loopback doesn't work.

    I say that because the script works fine now and i can understand it just going to test it with loopback.

    I will let you know...

    Z

  11. #161

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,710
    Thank Post
    3,246
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364
    Found it and here it is :

    Code:
    Dim SleepTime
    'upper school printers
    Dim IT1
    Dim IT2
    Dim IT3
    Dim IT4
    Dim IT6
    Dim TechU
    Dim LibrarySixth
    'lower school printers
    Dim ICT5
    Dim ICT6
    Dim ICT8
    Dim TechL
    Dim EdSupport
     
    Dim AName
    IT1 = "kyoceraM"
    IT2="kyit2"
    IT3="kyit3"
    IT4="kyit4"
    IT6="IT6Las"
    TechU="kdt"
    LibrarySixth="kyoceraL"
     
    ICT5="HPLaserJ"
    ICT6="HP-ICT6"
    ICT8="HP-ICT8"
    TechL="KyoceraF"
    EdSupport="BrotherEd"
     
    SleepTime=15
    Set WSHNetwork = CreateObject("WScript.Network")
    strComputer = WSHNetwork.ComputerName
    AName = Left(strComputer,Len(strComputer)-4)
    Select Case AName
        Case "IT1"
            call AddPrinter("\\cse2k01\",IT1)
            MsgBox "Added Printer : " & IT1
        Case "IT2"
            call AddPrinter("\\cse2k01\",IT2)
            MsgBox "Added Printer : " & IT2
        Case "IT3"
            call AddPrinter("\\cse2k01\",IT3)
            MsgBox "Added Printer : " & IT3
        Case "IT4"
            call AddPrinter("\\cse2k01\",IT4)
            MsgBox "Added Printer : " & IT4
        Case "DT"
            call AddPrinter("\\cse2k01\",TechU)
            MsgBox "Added Printer : " & TechU
        Case "IT6"
            call AddPrinter("\\cse2k01\",IT6)
            MsgBox "Added Printer : " & IT6
        Case "LibrarySixth"
            call AddPrinter("\\cse2k01\",LibrarySixth)
            MsgBox "Added Printer : " & LibrarySixth
        Case "ICT5"
            call AddPrinter("\\cse2k01\",ICT5)
            MsgBox "Added Printer : " & ICT5
        Case "ICT6"
            call AddPrinter("\\cse2k01\",ICT6)
            MsgBox "Added Printer : " & ICT6
        Case "ICT8"
            call AddPrinter("\\cse2k01\",ICT8)
            MsgBox "Added Printer : " & ICT8
        Case "DTLS"
            call AddPrinter("\\cse2k01\",TechL)
            MsgBox "Added Printer : " & TechL
        Case "ES"
            call AddPrinter("\\cse2k01\",EdSupport)
            MsgBox "Added Printer : " & EdSupport
    End Select
     
     
    Public Function AddPrinter(ByRef Server,ByRef strPrinter)
     
    Set WshNetwork = CreateObject("WScript.Network")
     
    rem ** This will delete existing printers **
    On Error Resume Next
    Set oPrinters = WshNetwork.EnumPrinterConnections
            For i = 1 to oPrinters.Count - 1 Step 2
                   WshNetwork.RemovePrinterConnection oPrinters.Item(i)
            Next
     
    rem ** Setup new printer connection **
    WshNetwork.AddWindowsPrinterConnection Server & strPrinter
     
     
    rem ** Pause Script **
    WScript.Sleep SleepTime*1000
     
    rem ** Setup default printer **
    WshNetwork.SetDefaultPrinter Server & strPrinter
    End Function
    Attached Files Attached Files

  12. #162
    linkazoid's Avatar
    Join Date
    May 2007
    Location
    London
    Posts
    644
    Thank Post
    118
    Thanked 89 Times in 73 Posts
    Rep Power
    78
    Quote Originally Posted by maniac View Post
    All you need to do it remove the single instance of the 'remove printer connections' loop at the beginning of the script, and place a copy of it under each 'case' statement. this would ensure it only removes printer connections on machines where it's going to add them again. It will make the script a bit longer, but it will work just fine.

    Mike.
    Can someone help me with this, we've been using this script for a while, but have now changed our GPOs and AD structure...

    How can I edit the original script not to delete printers from computers named ADMIN- or LAPTOP- ?

    Cheers,

    Michael

  13. #163
    linkazoid's Avatar
    Join Date
    May 2007
    Location
    London
    Posts
    644
    Thank Post
    118
    Thanked 89 Times in 73 Posts
    Rep Power
    78
    Bumpety Bump! Anyone?

  14. #164
    linkazoid's Avatar
    Join Date
    May 2007
    Location
    London
    Posts
    644
    Thank Post
    118
    Thanked 89 Times in 73 Posts
    Rep Power
    78
    I'm still having problems with the script. We would like this script to run as it should i.e delete printers then map according to the script below but we would like any computers named ADMIN-**** & LAPTOP-**** to be exempt and leave any printer mapped. If someone can shed some light and show me where i need to make changes that would be great.

    I have had to edit the script below due to it's vast character length, but attached script is full.

    Thanks

    Michael

    Code:
    ' Script to add network printers to workstations and thin clients
    '
    ' Author: Ric Charlton, 07/07/04, edited by Michael 24/12/09 - Added New Section to bottom
    
    ' Declare variables and enumerate existing printer connections
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set oPrinters = WshNetwork.EnumPrinterConnections
    
    Dim computerName
    computerName = LCase(WshNetwork.ComputerName)
    
    
    if (computerName = "svrts1") then _
    	computerName = LCase(WshShell.ExpandEnvironmentStrings("%CLIENTNAME%"))
    
    ' Degugging line> WScript.Echo "ComputerName variable: " & 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), 3) <> "lpt" And Left(oPrinters.Item(i), 3) <> "usb" then
                 	WshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true
                else WScript.Echo "No network printers found"
                end if
    Next
    
    ' Add printer connections dependant upon location
    
    Select Case (Left(computerName, 3))
    
    	Case "lrc"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\lrc"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\lrc"
    		
    	Case "saw"
    		WshNetwork.AddWindowsPrinterConnection "\\saw\saw"
    		WshNetwork.SetDefaultPrinter "\\saw\saw"	
    	
    		End Select
    
    Select Case (Left(computerName, 4))
    	Case "art1"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\ArtColourA3_PS"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\art"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\art"
    	Case "rm30"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Room305"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Room305"
    	Case "art2"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\ArtColourA3_PS"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\art"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\art"
    		Case "rm30"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\mathstemp"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\mathstemp"	
    	Case "rm31"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\room305"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\305"
    	Case "rm71"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Humanities"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Humanities"
    	Case "rm72"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Humanities"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Humanities"
    	Case "rm73"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Humanities"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Humanities"
    	Case "rm66"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Room666"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Room666"
    	Case "mro-"
    		WshNetwork.AddWindowsPrinterConnection "\\print\sharpphotocopier"
    		WshNetwork.SetDefaultPrinter "\\print\sharpphotocopier"
    
    		End Select
    	
    	Case "lrc"
    		Select Case (Left(computerName, 4))
    	Case "lrc-"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\lrc"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\lrc"
    	Case "lrcl"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\lrc"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\lrc"
    	
    		End Select
    		
    	Case "rm14"
    		Select Case (Left(computerName, 5))
    	Case "rm142"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\l2l8"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\l2l8"
    	Case "rm144"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\l2l9"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\l2l9"
    
    		End Select
    	
    	Case "rm41"
    		Select Case (Left(computerName, 5))
    	Case "rm412"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Room412"	
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Room412Colour"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Room412"
    	Case "rm411"	
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\room411"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\room411"
    		
    		End Select
    
    	Case "rm33"
    		Select Case (Left(computerName, 5))
    	Case "rm334"	
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\englishoffice"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\englishoffice"
    		
    		End Select
    
    	Case "rm61"
    		Select Case (Left(computerName, 5))
    	Case "rm611"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Room611"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Room611"
    	Case "rm612"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Room612Color"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Room612Color"
    		
    		End Select
    	
    	Case "rm63"
    		Select Case (Left(computerName, 5))
    	Case "rm632"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\l2l7"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\l2l7"
    		
    		End Select
    
    	Case "rm51"
    		Select Case (Left(computerName, 5))
    	Case "rm513"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Room513"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Room513"
    	Case "rm511"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\englishOffice"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\englishOffice"
    	Case "rm512"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\englishOffice"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\englishOffice"
    	
    		End Select
    
    	Case Else
    		' WScript.Echo "No default printers added"
    End Select
    
    Select Case (computerName)
    	Case "admin-2454"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\timeout"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\timeout"
    
    End Select
    Attached Files Attached Files

  15. #165
    linkazoid's Avatar
    Join Date
    May 2007
    Location
    London
    Posts
    644
    Thank Post
    118
    Thanked 89 Times in 73 Posts
    Rep Power
    78
    It appears that we have another problem at the mo.

    It seems that if the printer is not on, for example if Room412 is not on the Room412 Colour does not get mapped either.

    Code:
    Case "rm412"
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Room412"	
    		WshNetwork.AddWindowsPrinterConnection "\\sharepoint\Room412Colour"
    		WshNetwork.SetDefaultPrinter "\\sharepoint\Room412"
    Is there any was I can force it to carry on if a printer is swithed off?

    This did not seem to be a problem until recently
    Thanks Michael

SHARE:
+ Post New Thread
Page 11 of 11 FirstFirst ... 7891011

Similar Threads

  1. logon script for printer
    By ozzy in forum Scripts
    Replies: 6
    Last Post: 22nd November 2007, 03:03 PM
  2. Printer Script
    By faza in forum Scripts
    Replies: 9
    Last Post: 14th September 2007, 08:30 AM
  3. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM
  4. Add printer script not workling
    By mark in forum Windows
    Replies: 6
    Last Post: 15th September 2005, 10:07 AM
  5. Script to delete printer
    By tosca925 in forum Scripts
    Replies: 2
    Last Post: 31st August 2005, 07:45 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
  •