Network Logon script problem

I have created the network logon script below, however it gives an error on:
Line: 16
Char: 45
Error: Expected end of statement
Code: 800A0401
Can't figure out correct syntax for it.

Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2
Dim strDriveLetter1, strDriveLetter2

strDriveLetter1 = "F:"
strDriveLetter2 = "P:"
strDriveLetter3 = "S:"
strRemotePath1 = "\Alpha-DC1Fax"
strRemotePath2 = "\Alpha-DC1Public"
strRemotePath3 = "\Alpha-DC1Software"

Set objNetwork = CreateObject("WScript.Network")

' Section which maps two drives, F: and P: and S:
objNetwork.MapNetworkDrive = strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive = strDriveLetter2, strRemotePath2
objNetwork.MapNetworkDrive = strDriveLetter3, strRemotePath3

' Extra code just to add a message box
WScript.Echo "Map drives " & strDriveLetter1 & " & " & strDriveLetter2 & " & " & strDriveLetter3

Wscript.Quit


Thanks for the help!

Comments

  • : ' Section which maps two drives, F: and P: and S:
    [blue] Actually there 3 drives - F,P and S but it's nor your problem[/blue]
    [red] Yours problem is here
    objNetwork.MapNetworkDrive = strDriveLetter1, strRemotePath1
    [/red]
    Shoud be
    [code]
    objNetwork.MapNetworkDrive = strDriveLetter2 [b][blue] & "," & [/blue][/b]strRemotePath2
    [/code]

  • I've fixed that and added for the third drive letter I missed, but now i'm getting another error:
    Line: 15
    Char: 1
    Error: Object doesn't support this property or method:'MapNetworkDrive'
    Code: 800A01b6
    Source: MS VBScript runtime error

    Option Explicit
    Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3
    Dim strDriveLetter1, strDriveLetter2, strDriveLetter3

    strDriveLetter1 = "F:"
    strDriveLetter2 = "P:"
    strDriveLetter3 = "S:"
    strRemotePath1 = "\Alpha-DC1Fax"
    strRemotePath2 = "\Alpha-DC1Public"
    strRemotePath3 = "\Alpha-DC1Software"

    Set objNetwork = CreateObject("WScript.Network")

    ' Section which maps three drives, F: and P: and S:
    objNetwork.MapNetworkDrive = strDriveLetter1 & "," & strRemotePath1
    objNetwork.MapNetworkDrive = strDriveLetter2 & "," & strRemotePath2
    objNetwork.MapNetworkDrive = strDriveLetter3 & "," & strRemotePath3

    ' Extra code just to add a message box
    WScript.Echo "Map drives " & strDriveLetter1 & " & " & strDriveLetter2 & " & " & strDriveLetter3

    Wscript.Quit

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories