GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

Changing default printer script

Home Forums Scripting General Scripting Changing default printer script

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    cmcf
    Member
    #122692

    Hi,

    I’m looking for a script that changes the default to another printer if the
    local printer is not installed on the local PC.

    At the moment i have this:

    Code:
    Option Explicit

    Dim objNetwork

    Set objNetwork = CreateObject(“WScript.Network”)

    Dim WshShell: Set WshShell = CreateObject(“Wscript.Shell”)

    Dim strLocal1, strLocal2, strUNCPrinter1, strUNCPrinter2, strLocal
    strUNCPrinter1 = “\print-serverHP Universal Printer for accounts”
    strUNCPrinter2 = “\print-serverRicoh Aficio 1224C PCL 5c”
    strLocal1 = “\print-serverHPDesignJet”
    strLocal2 = “\print-serverDYMO”
    strLocal = “Accounts Printer”

    objNetwork.AddWindowsPrinterConnection strUNCPrinter1
    objNetwork.AddWindowsPrinterConnection strUNCPrinter2
    objNetwork.AddWindowsPrinterConnection strLocal1
    objNetwork.AddWindowsPrinterConnection strLocal2

    objNetwork.SetDefaultPrinter strLocal

    WScript.Quit

    strLocal is the locally installed printer but if it doesn’t exist i want the
    default printer to be strUNCPrinter2.

    Please help, many thanks

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.