Log on Scripts - Printer Mapping via vbs

Hi all hope you can help,

I'm currently practicing with a few servers and trying to work out how to use login scripts to map printers for users upon log on.

What i need is a VBS script to remove all previous printer entries, map two new shared printers and then set one of them as default.
I have created a LOGON.bat which maps drives and sets the time from the server with an additional line inside ‘CALL \\servername\SYSVOL\curriculum.local\scripts\printer.vbs ‘
Then in the same location as the LOGON.bat i have created a printer.vbs file with the following inside.

Quote:

on error resume next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\servername\HP3600N"
objNetwork.AddWindowsPrinterConnection "\\servername\HPCP1515n"
objPrinter.SetDefaultPrinter "\\servername\HP3600N"


This does not seem to give me the desired effect, what am i doing wrong? The printer share names are correct.
This is a 2008 server if that helps at all.

Thanking in advanced,

Steve
2 answers Last reply
More about scripts printer mapping
  1. here a vbs i worked on to map network printers and sets it to one to default and delete the old ones

    Option Explicit
    Dim netPrinter, UNCpath
    UNCpath = "\\my-print-svr\my-printer"
    Set netPrinter = CreateObject("WScript.Network")
    netPrinter.AddWindowsPrinterConnection UNCpath
    ' Here is where we set the default printer
    netPrinter.SetDefaultPrinter UNCpath

    UNCpath = "\\my-print-svr\my-printer2"
    netPrinter.AddWindowsPrinterConnection UNCpath
    'Adds second printer

    Dim objNetwork, strUNCPrinter
    strUNCPrinter = "\\my-print\my-printer1"
    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.RemovePrinterConnection strUNCPrinter
    'Deletes printer

    Dim objNetwork1, strUNCPrinter1
    strUNCPrinter1 = "\\my-print\my-printer2"
    Set objNetwork1 = CreateObject("WScript.Network")
    objNetwork1.RemovePrinterConnection strUNCPrinter1
    'Deletes second printer
    Wscript.Quit


    I bolded the lines u want to change
  2. also if you want a prompt put this at the end of each printer statment

    WScript.Echo "Check Printers folder NO: " & strUNCPrinter
Ask a new question

Read More

VBS Printers Servers Networking