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 2 of 11 FirstFirst 123456 ... LastLast
Results 16 to 30 of 165
Scripts Thread, A Printer Script in Coding and Web Development; Didnt realise that , was on a lunch break and just wanted to download them lol....
  1. #16

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361

    Re: A Printer Script

    Didnt realise that , was on a lunch break and just wanted to download them lol.

  2. #17

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180

    Re: A Printer Script

    BUMP! Some people have missed this recently and may find it useful.

  3. #18
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    2,946
    Thank Post
    278
    Thanked 262 Times in 189 Posts
    Rep Power
    114

    Re: A Printer Script

    in this script is there a way to delete local printers???
    Also, im in the market for a decent VBscript combined with AD book, can anyone recommend any?

    Tim

  4. #19

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: A Printer Script

    Just remove this line:

    Code:
    if Left(oPrinters.Item(i), 3) <> "lpt" And Left(oPrinters.Item(i), 3) <> "usb" then
    and it'll nuke local printers.

  5. #20
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    2,946
    Thank Post
    278
    Thanked 262 Times in 189 Posts
    Rep Power
    114

    Re: A Printer Script

    ok, ive removed that line, but nothing seems to be happening, is this correct:

    Code:
    Select Case (computerName)
    	Case "pand"
    		
    ' Delete Printer
    	For i = 0 to oPrinters.Count - 1 step 2
    			On Error Resume Next
    				
    		wshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true
    				
    Next
    	
    
    End Select
    Im sure im doing something wrong somewhere

  6. #21

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: A Printer Script

    why is it in a select case?

  7. #22
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    2,946
    Thank Post
    278
    Thanked 262 Times in 189 Posts
    Rep Power
    114

    Re: A Printer Script

    so it would only apply to that computer

  8. #23

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: A Printer Script

    What sort of printer connection are you trying to remove?

  9. #24
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    2,946
    Thank Post
    278
    Thanked 262 Times in 189 Posts
    Rep Power
    114

    Re: A Printer Script

    A local port \\server\printer

  10. #25

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: A Printer Script

    The standard script will remove those, you don't need to do anything fancy.

  11. #26
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    41

    Re: A Printer Script

    \\server\printer are network printers and as geoff said will be removed with the standard script, so are they not removed?

    What is the whole script you are running?

    You might want to add in some error traps to see if there are any errors, or remove the 'On Error Resume Next'.

  12. #27
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    2,946
    Thank Post
    278
    Thanked 262 Times in 189 Posts
    Rep Power
    114

    Re: A Printer Script

    This is what im running at the mo

    Code:
    ' Script to add network printers to workstations and thin clients
    '
    ' Author: Ric Charlton, 07/07/04 (amended 26/08/05)
    
    ' 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)
    
    WScript.Echo "computername variable: " & (Left(computerName, 4))
    
    
    
    Select Case (Left(computerName, 4))
    	Case "pand"
    
    ' Delete Printer
    	For i = 0 to oPrinters.Count - 1 step 2
    			On Error Resume Next
    			
    		wshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true
    			
    next	
    
    		WshNetwork.AddwindowsPrinterConnection "\\hades\R13-2015"
    		WshNetwork.setDefaultPrinter "\\hades\R13-2015"
    
    End Select
    The only part that doesnt work is "wshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true" that will not delete local printers

  13. #28
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,996
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106

    Re: A Printer Script

    Take out the
    Code:
    On Error Resume Next
    and see if you get any error messages.

  14. #29
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    2,946
    Thank Post
    278
    Thanked 262 Times in 189 Posts
    Rep Power
    114

    Re: A Printer Script

    i dont get any error messages, it deletes the \\hades\R13-2015 printer and puts it back but thats not the correct printer to delete. Ive got a \\hades\LY1-2200 local port printer and its not deleting it.

  15. #30

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,802
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: A Printer Script

    permissions problem?

SHARE:
+ Post New Thread
Page 2 of 11 FirstFirst 123456 ... LastLast

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
  •