+ Post New Thread
Results 1 to 2 of 2
Scripts Thread, printer script again (sorry) in Coding and Web Development; Posted this the other night just before the big 'meltdown' at fasthosts hope it wasn't yet another printer script request ...
  1. #1
    chrbb's Avatar
    Join Date
    Oct 2005
    Location
    Midlands
    Posts
    1,508
    Thank Post
    141
    Thanked 67 Times in 62 Posts
    Rep Power
    47

    printer script again (sorry)

    Posted this the other night just before the big 'meltdown' at fasthosts hope it wasn't yet another printer script request that did it

    I have two seperate vbs scripts at logon, one to delete networked printers and one to connect to network printers, what I really want but am too dim to do it, is one script that will delete networked printers if they exist and connect/install currently used network printers.


    Nice to be back - well done!

  2. #2
    roty80's Avatar
    Join Date
    May 2008
    Location
    Sheffiled
    Posts
    86
    Thank Post
    14
    Thanked 6 Times in 6 Posts
    Rep Power
    27

    script

    could try:

    On error resume next

    'Remove's All Network Objects (Printers and Drives)

    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set oDrives = WshNetwork.EnumNetworkDrives
    Set oPrinters = WshNetwork.EnumPrinterConnections
    For i = 0 to oDrives.Count - 1 Step 2
    WshNetwork.RemoveNetworkDrive oDrives.Item(i),true,true
    Next
    For i = 0 to oPrinters.Count - 1 Step 2
    WshNetwork.RemovePrinterConnection oPrinters.Item(i+1)

    Next

    '-----------------------------------------------------------

    'Map Printers Based On Computer OU Membership

    Set objSysInfo = CreateObject("ADSystemInfo")
    strName = objSysInfo.ComputerName

    arrComputerName = Split(strName, ",")
    arrOU = Split(arrComputerName(1), "=")
    strComputerOU = arrOU(1)

    Set objNetwork = CreateObject("WScript.Network")

    Select Case strComputerOU

    '-----------------------------------------------------

    Case "OU name"
    objNetwork.AddWindowsPrinterConnection "\\server\printername"
    objNetwork.SetDefaultPrinter "\\server\printername"



    Obviously put your OU's and printer share names in and repeat for all printers and OU's
    Last edited by roty80; 11th July 2008 at 12:29 PM. Reason: spelling

  3. Thanks to roty80 from:

    chrbb (23rd September 2008)

SHARE:
+ Post New Thread

Similar Threads

  1. A Printer Script
    By Ric_ in forum Scripts
    Replies: 164
    Last Post: 1st October 2010, 10:11 AM
  2. Replies: 13
    Last Post: 20th February 2008, 04:29 PM
  3. Printer Script
    By faza in forum Scripts
    Replies: 9
    Last Post: 14th September 2007, 08:30 AM
  4. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM
  5. Hacked together printer script
    By Halfmad in forum Scripts
    Replies: 8
    Last Post: 25th June 2007, 01:29 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
  •