Drive Check Error

Home Forums Scripting General Scripting Drive Check Error

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    MetalSmith
    Member
    #127952

    Ok, this is a piece of my script I am trying to get through. My problem is for some reason when this script runs the DriveCheck subroutine fails to see my K: Drive on the first run. Once the K: Drive maps and you run this script again it will see the K: Drive.

    This is a problem because users are logging into this drive over a WAN and I need to make it user friendly so I came up with an idea to verify if the drive has mapped so in the case the user put in a bad username or password it will prompt the user to retry. Because the script on the first run can’t see the K: Drive after it just mapped it errors out even though it really mapped. Run the script again and it will see the drive. GRRRRRR Well here it is. You also need a third party DLL to get the password box that I found here:

    http://internet.cybermesa.com/~bstewart/passdlg/

    Any Ideas?
    Thanks!!

    On Error Resume Next
    Dim intDrive
    Dim CheckDrive
    Dim WshNetwork
    Dim sDriveLetter
    Dim AlreadyConnected
    Dim objPassDlg
    Dim sLabel
    Dim objShell
    Dim strMessage
    Dim MessageBox
    Set WshNetwork = WScript.CreateObject(“WScript.Network”)
    Set CheckDrive = WshNetwork.EnumNetworkDrives
    Set objPassDlg = CreateObject(“PassDlg.LogonDialog”)
    Set objShell = CreateObject(“Shell.Application”)

    sDriveLetter = “K:”
    sLabel = “AUM Common”

    strMessage = MsgBox(“Will you need AUM’s Common Drive Today? “, 36, “Welcome To AWA DET”)
    If strMessage = 7 Then WScript.Quit
    objPassDlg.Confirm = True
    objPassDlg.ShowDialog “Connecting to AUM’s Common Drive”
    If objPassDlg.Canceled Then
    ‘Wscript.Echo “Cancelled”
    wscript.quit
    Else
    WshNetwork.MapNetworkDrive “K:”, “\xxx.xxx.xxx.xxxCommon”, False, objPassDlg.UserName, objPassDlg.Password
    objShell.NameSpace(sDriveLetter).Self.Name = sLabel
    WScript.Sleep (5000)
    End If

    Call DriveCheck

    Sub DriveCheck
    For intDrive = 0 To CheckDrive.Count – 1 Step 2
    If CheckDrive.Item(intDrive) = sDriveLetter _
    Then AlreadyConnected = True
    Next
    If AlreadyConnected = True Then
    MsgBox “Drive Mapping Successfull!” & vbCrLf & vbCrLf & “Welcome to AUM’s Common Drive.” _
    ,64,”Connecting to AUM’s Common Drive”
    WScript.Quit
    Else
    MessageBox = MsgBox (“Drive Mapping Unsuccessfull” & vbCrLf & vbCrLf & _
    “Please check your password and make sure your username is as follows. ” _
    & vbCrLf & vbCrLf & “Example: aisinworldusername”,21,”Connecting to AUM’s Common Drive”)
    End If
    End Sub[/CODE][CODE]On Error Resume Next
    Dim intDrive
    Dim CheckDrive
    Dim WshNetwork
    Dim sDriveLetter
    Dim AlreadyConnected
    Dim objPassDlg
    Dim sLabel
    Dim objShell
    Dim strMessage
    Dim MessageBox
    Set WshNetwork = WScript.CreateObject(“WScript.Network”)
    Set CheckDrive = WshNetwork.EnumNetworkDrives
    Set objPassDlg = CreateObject(“PassDlg.LogonDialog”)
    Set objShell = CreateObject(“Shell.Application”)

    sDriveLetter = “K:”
    sLabel = “AUM Common”

    strMessage = MsgBox(“Will you need AUM’s Common Drive Today? “, 36, “Welcome To AWA DET”)
    If strMessage = 7 Then WScript.Quit
    objPassDlg.Confirm = True
    objPassDlg.ShowDialog “Connecting to AUM’s Common Drive”
    If objPassDlg.Canceled Then
    ‘Wscript.Echo “Cancelled”
    wscript.quit
    Else
    WshNetwork.MapNetworkDrive “K:”, “\xxx.xxx.xxx.xxxCommon”, False, objPassDlg.UserName, objPassDlg.Password
    objShell.NameSpace(sDriveLetter).Self.Name = sLabel
    WScript.Sleep (5000)
    End If

    Call DriveCheck

    Sub DriveCheck
    For intDrive = 0 To CheckDrive.Count – 1 Step 2
    If CheckDrive.Item(intDrive) = sDriveLetter _
    Then AlreadyConnected = True
    Next
    If AlreadyConnected = True Then
    MsgBox “Drive Mapping Successfull!” & vbCrLf & vbCrLf & “Welcome to AUM’s Common Drive.” _
    ,64,”Connecting to AUM’s Common Drive”
    WScript.Quit
    Else
    MessageBox = MsgBox (“Drive Mapping Unsuccessfull” & vbCrLf & vbCrLf & _
    “Please check your password and make sure your username is as follows. ” _
    & vbCrLf & vbCrLf & “Example: aisinworldusername”,21,”Connecting to AUM’s Common Drive”)
    End If
    End Sub[/CODE]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.