No announcement yet.

VBS logon script does not map all drives.

  • Filter
  • Time
  • Show
Clear All
new posts

  • VBS logon script does not map all drives.

    I am using the following script to log in users. The script is being pushed out be a GPO in a 2003 server/XP Pro enviorment.

    ' VBScript Source File -- Created with XLnow OnScript
    ' AUTHOR:  alan 
    ' DATE:    10/1/2009
    ' COMMENT: <comment>
      'The following Script logs into the Network
      'Script Written by Paul F 04-08-2002
        'Variables below are used for connecting network drives
        Dim objNetwork, strName
        Set objNetwork = CreateObject("WScript.Network")
        'Variables below are used for enumerating (listing) drives enable for diagnostic
        'Set WshNetwork = WScript.CreateObject("WScript.Network") 
        'Set oDrives = WshNetwork.EnumNetworkDrives
        'Variables below are used for the win pop-up network message
        Dim WshShell, BtnCode
        Set WshShell = WScript.CreateObject("WScript.Shell")
          On Error Resume Next
            'get user name
          While strName = ""
             strName = objNetwork.UserName
             WScript.Sleep 100
          'Add network drives below to make sure drives are disconnect 
          'before connecting new drives to network shares
              WshNetwork.RemoveNetworkDrive "X:"
              WshNetwork.RemoveNetworkDrive "Z:"
              WshNetwork.RemoveNetworkDrive "W:"
          ' Add network drives below to connect users to network shares
          'connect to OAKNTFS 1
              objNetwork.MapNetworkDrive "W:", "\\ts01\student", False
          'connect to OAKNTFS 2
              objNetwork.MapNetworkDrive "Z:", "\\metrolabserver\metrolab", False
          'This lists the network drives that the user is connected to
          'Enable for Diagnostics only
          '  For i = 0 to oDrives.Count - 1 Step 2
          '    WScript.Echo "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)
          '  Next
          'The code below used for the win pop-up network message
             BtnCode = WshShell.Popup("Network Drives Connected", 5, "SLCHC Login", 0 + 64)
    I see the pop up box showing the scrip has run, but I only have a Z: drive.

    If I run the script after the workstation is already logged in, both drives appear.

    What am I doing wrong?
    Last edited by aportman; 1st October 2009, 17:07. Reason: ask the question

  • #2
    Re: VBS logon script does not map all drives.

    Try changing wshNetwork.RemoveNetworkDrive "W:" to objNetwork.RemoveNetworkDrive "W:"

    I would also remove the On Error Resume Next command and watch for more errors.