Announcement

Collapse
No announcement yet.

Script to map Printers

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script to map Printers

    hi guys,

    i like to use this script for mapping printer according to the room they belong.
    there is one laptop named "jan" and 9 pc's name starting LS01 to LS09.

    whats wrong with this script, when i run it i get the follwing:

    line: 18
    Char: 53
    error: Expected end of statement
    code: 800A0401
    Source: Microsoft VBscript compilation error



    Option Explicit

    Dim Str
    Dim CompName
    Dim WshNetwork ' Object variable

    ' Create a new WshNetwork object to access network properties.
    Set WshNetwork = WScript.CreateObject("WScript.Network")

    CompName = WshNetwork.ComputerName

    If InStr(CompName, "jan") = 1 Then
    WshNetwork.AddWindowsPrinterConnection("\\pdcserve r\HPColorL")
    WshNetwork.SetDefaultPrinter "\\pdcserver\HPColorL"
    ElseIf InStr(CompName, "LS01") = 1 Then
    WshNetwork.AddWindowsPrinterConnection("\\pdcserve r\HPColorL")
    WshNetwork.SetDefaultPrinter "\\pdcserver\HPColorL")
    ElseIf InStr(CompName, "CR") = 1 Then
    Str = "Hello"
    Else
    Str = "Hello"
    End If

    '*** End




    thanks

    Z

  • #2
    Re: Script to map Printers

    WshNetwork.SetDefaultPrinter "\\pdcserver\HPColorL")

    is missing its opening '('
    Cheers,

    Rick

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

    2006-2099 R Valstar. This post is offered "as is" for discussion purposes only with no express or implied warranty of any kind including, but not limited to, correctness or fitness for use. Nothing herein shall be construed as advice. Attempting any activity based on information in this post is done at your own risk.

    Comment


    • #3
      Re: Script to map Printers

      is this how how it should be..

      WshNetwork.SetDefaultPrinter ("\\pdcserver\HPColorL")

      if yes is rest of the script ok?

      Thanks

      Comment


      • #4
        Re: Script to map Printers

        Please search the forum first. It already passed a few times.
        Marcel
        Technical Consultant
        Netherlands
        http://www.phetios.com
        http://blog.nessus.nl

        MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
        "No matter how secure, there is always the human factor."

        "Enjoy life today, tomorrow may never come."
        "If you're going through hell, keep going. ~Winston Churchill"

        Comment

        Working...
        X