Cannot set default printer via .vbs script

Home Forums Scripting General Scripting Cannot set default printer via .vbs script

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    pksupport
    Member
    #154561

    I am using a VBS script to set the default printer in our Library (XP clients only):

    It came courtesy of Guy Thomas:

    ‘ SetDefaultPrinter.vbs – Windows logon script example
    ‘ PrintersDefault.vbs – Set the default printer
    ‘ VBScript – to map a network printer
    ‘ Author Guy Thomas [url]http://computerperformance.co.uk/[/url]
    ‘ Version 1.4 – April 24th 2010
    ‘ —————————————————-‘
    Option Explicit
    Dim objNetwork, strUNCPrinter
    strUNCPrinter = “\PRINTSERVER1Ricoh Laser”
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.AddWindowsPrinterConnection strUNCPrinter

    ‘ Here is where we set the default printer to strUNCPrinter
    objNetwork.SetDefaultPrinter strUNCPrinter
    WScript.Echo “Check the Printers folder for : ” & strUNCPrinter

    WScript.Quit

    ‘ End of Guy’s Windows logon example VBScript. [/CODE]
    This works well except that the computers have SMART Notebook installed and the SMART Notebook Printer keeps re-appearing and stops the script from setting the default printer, I presume because it comes later in the log in process. I delete it and it comes back. Can anyone provide pointers to stop this?

    Thanks for you time – it’s much appreciated.[CODE]’ SetDefaultPrinter.vbs – Windows logon script example
    ‘ PrintersDefault.vbs – Set the default printer
    ‘ VBScript – to map a network printer
    ‘ Author Guy Thomas http://computerperformance.co.uk/
    ‘ Version 1.4 – April 24th 2010



    Option Explicit
    Dim objNetwork, strUNCPrinter
    strUNCPrinter = “\PRINTSERVER1Ricoh Laser”
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.AddWindowsPrinterConnection strUNCPrinter

    ‘ Here is where we set the default printer to strUNCPrinter
    objNetwork.SetDefaultPrinter strUNCPrinter
    WScript.Echo “Check the Printers folder for : ” & strUNCPrinter

    WScript.Quit

    ‘ End of Guy’s Windows logon example VBScript. [/CODE]
    This works well except that the computers have SMART Notebook installed and the SMART Notebook Printer keeps re-appearing and stops the script from setting the default printer, I presume because it comes later in the log in process. I delete it and it comes back. Can anyone provide pointers to stop this?

    Thanks for you time – it’s much appreciated.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.