+ Post New Thread
Results 1 to 4 of 4
Scripts Thread, Sorry Logon Printer Script.... again in Coding and Web Development; Hi I have had a lot of problems recently at one of the primary schools i support and i have ...
  1. #1
    DSapseid's Avatar
    Join Date
    Feb 2007
    Location
    West Sussex
    Posts
    1,153
    Thank Post
    130
    Thanked 54 Times in 47 Posts
    Rep Power
    38

    Sorry Logon Printer Script.... again

    Hi I have had a lot of problems recently at one of the primary schools i support and i have got them it pretty much all working again now apart from one thing - the printers!!! Sorry i know its been covered before but my brain is fried and i cant think of where to start.

    All i need is a simple script to delete any existing printers, local/network then add one shared printer from the server. It is just an ICT suite so it doesnt need to look at locations.

    I dont mind what language its in. batch/vbs/autoIT i dont mind it just needs to run as a logon script.

    I would be eternally grateful!

  2. #2

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,069 Times in 625 Posts
    Rep Power
    740
    Code:
    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 ** Adds printers - new line for each printer **
    Set WshNetwork = CreateObject("WScript.Network")
    WshNetwork.AddWindowsPrinterConnection "\\SRVNAME\PTRSHARE"
    WshNetwork.AddWindowsPrinterConnection "\\SRVNAME\PTRSHARE2"
    
    rem ** Setup default printer **
    WshNetwork.SetDefaultPrinter "\\SRVNAME\PTRSHARE"

  3. Thanks to mattx from:

    DSapseid (23rd September 2008)

  4. #3
    DSapseid's Avatar
    Join Date
    Feb 2007
    Location
    West Sussex
    Posts
    1,153
    Thank Post
    130
    Thanked 54 Times in 47 Posts
    Rep Power
    38
    Thanks alot, will try out tommorow.

  5. #4
    contink's Avatar
    Join Date
    Jul 2006
    Location
    South Yorkshire
    Posts
    3,791
    Thank Post
    303
    Thanked 327 Times in 233 Posts
    Rep Power
    118
    You may find that some printers will refuse to be deleted because they were added to the local system some other way. There's some discussion about it in various threads but just a note so you don't think you're losing your mind.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 8
    Last Post: 25th February 2009, 09:50 AM
  2. Replies: 13
    Last Post: 20th February 2008, 04:29 PM
  3. logon script for printer
    By ozzy in forum Scripts
    Replies: 6
    Last Post: 22nd November 2007, 03:03 PM
  4. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM
  5. Yet another Logon Script
    By ajbritton in forum Windows
    Replies: 3
    Last Post: 19th June 2006, 09:47 AM

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
  •