Any WSH experts?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • s2avant95M
    S2Forum Extremist
    • Mar 2004
    • 1217
    • Home: England Current: United States

    #1

    Any WSH experts?

    Please PM me if you know about Windows Scripting Host, namely i am trying to run a login script for Active Directory on a Windows 2003 domain. In fact it is the example given by Microsoft on their Technet site, it displays a syntax error and i'll be ******ed if i can spot it. (This is copy and pasted from the M$ site, all i did was replace with our groups/printers etc). It fails on line 6......

    Const ENGINEERING_GROUP = "cn=engineering"
    Const FINANCE_GROUP = "cn=finance"
    Const HUMAN_RESOURCES_GROUP = "cn=human resources"

    Set wshNetwork = CreateObject("WScript.Network")
    wshNetwork.MapNetworkDrive "h:",
    "\\FileServer\Users\" & wshNetwork.UserName

    Set ADSysInfo = CreateObject("ADSystemInfo")
    Set CurrentUser = GetObject("LDAP://" &
    ADSysInfo.UserName)
    strGroups = LCase(Join(CurrentUser.MemberOf))

    If InStr(strGroups, ENGINEERING_GROUP) Then

    wshNetwork.MapNetworkDrive "g:",
    "\\FileServer\Engineering\"
    wshNetwork.AddWindowsPrinterConnection
    "\\PrintServer\EngLaser"
    wshNetwork.AddWindowsPrinterConnection
    "\\PrintServer\Plotter"
    wshNetWork.SetDefaultPrinter
    "\\PrintServer\EngLaser"

    ElseIf InStr(strGroups, FINANCE_GROUP) Then

    wshNetwork.MapNetworkDrive "g:",
    "\\FileServer\Finance\"
    wshNetwork.AddWindowsPrinterConnection
    "\\PrintServer\FinLaser"
    wshNetWork.SetDefaultPrinter
    "\\PrintServer\FinLaser"

    ElseIf InStr(strGroups, HUMAN_RESOURCES_GROUP) Then

    wshNetwork.MapNetworkDrive "g:",
    "\\FileServer\Human Resources\"
    wshNetwork.AddWindowsPrinterConnection
    "\\PrintServer\HrLaser"
    wshNetWork.SetDefaultPrinter
    "\\PrintServer\HrLaser"

    End If
    Tim

    1995 S2 Avant, ruby red - ** SOLD TO ROSS **
    Golf Rallye G60 ** SOLD **
    Golf MK2 Oaky with R32 engine
    Audi A6 Avant 1.9 TDi 130
    Golf MK2 8v Race car
  • Jamo
    Retired OG Mod
    • Mar 2004
    • 21750
    • Country: United Kingdom

    #2
    Is that line 6 including the space or line 6 without?

    I'll ask my I.T scriptor if he's in

    I would bet it doesn't like the amphersand

    Comment

    • s2avant95M
      S2Forum Extremist
      • Mar 2004
      • 1217
      • Home: England Current: United States

      #3
      I think it starts with line 0, so line 6 should be:

      "\\FileServer\Users\" & wshNetwork.UserName


      Tim

      1995 S2 Avant, ruby red - ** SOLD TO ROSS **
      Golf Rallye G60 ** SOLD **
      Golf MK2 Oaky with R32 engine
      Audi A6 Avant 1.9 TDi 130
      Golf MK2 8v Race car

      Comment

      • Jamo
        Retired OG Mod
        • Mar 2004
        • 21750
        • Country: United Kingdom

        #4
        lines 5 and 6 should be one line ala this example http://msdn.microsoft.com/library/de...0c42a4ed02.asp

        I think anyway give me Unix any old day!

        Comment

        • S2 Ant
          S2Forum Possessed
          • Jul 2003
          • 3682
          • Country: United Kingdom

          #5
          Yeh it should be on 1 line, looks like there are a few other lines thare are the same as well.
          If you need to break the lines up you need to put a _ at the end of the line and a & at the start of the next.

          Think thats right from memory. You may need to split up lines sometimes as there is a maximum length for the number of characters on 1 line
          Ant

          2007 Mk5 Golf GTi, 3 door, DSG, REVO Stg 2 and other goodies
          2011 Kawasaki Z1000

          Comment

          • S2 Ant
            S2Forum Possessed
            • Jul 2003
            • 3682
            • Country: United Kingdom

            #6
            Ive actually got a M$ scripters guide CD thing, proper official thing thats meant for training and learning somewhere as i try to use scripting for a lot of stuff as well, makes my life sooooooo much easier!!
            Ant

            2007 Mk5 Golf GTi, 3 door, DSG, REVO Stg 2 and other goodies
            2011 Kawasaki Z1000

            Comment

            Working...