VBScript Bug?

Home Forums Scripting General Scripting VBScript Bug?

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

    Ok after a recent post http://forums.petri.com/showthread.php?t=18604 I made the nessacary changes but now I see a new problem develop.

    For some reason when the (sDriveLetter) is mapped in my (MapDrive) subroutine the wscript.sleep (5000) and Call DriveCheck statements right under it work fine. BUT if the mapping fails due to a bad password or such and the drive didn’t map, those 2 statements or any statement added will be ignored completely if its under that line of code and the script finishes out.

    The third party DLL can be found here:

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

    Any Idea whats causeing that? or is that a bug?

    On Error Resume Next
    Dim intDrive
    Dim CheckDrive
    Dim WshNetwork
    Dim sDriveLetter
    Dim AlreadyConnected
    Dim objPassDlg
    Dim sLabel
    Dim objShell
    Dim strMessage
    Dim MessageBox

    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
    Else
    Call MapDrive
    End If

    Sub MapDrive
    Set WshNetwork = WScript.CreateObject(“WScript.Network”)
    Set objPassDlg = CreateObject(“PassDlg.LogonDialog”)
    Set objShell = CreateObject(“Shell.Application”)
    objPassDlg.Confirm = True
    objPassDlg.ShowDialog “Connecting to AUM’s Common Drive”
    If objPassDlg.Canceled Then
    ‘Wscript.Echo “Cancelled”
    WScript.quit
    [B][U] Else
    WshNetwork.MapNetworkDrive sDriveLetter, “\x.x.x.xCommon”, False, objPassDlg.UserName, objPassDlg.Password
    objShell.NameSpace(sDriveLetter).Self.Name = sLabel
    WScript.Sleep(5000)
    Call DriveCheck[/U][/B]
    End If
    End Sub

    Sub DriveCheck
    Set CheckDrive = WshNetwork.EnumNetworkDrives
    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”)
    Call Retry
    End If
    End Sub

    Sub Retry
    If MessageBox = 4 Then
    Call MapDrive
    If MessageBox = 2 Then
    WScript.Quit
    End if
    Else
    WScript.Quit
    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

    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
    Else
    Call MapDrive
    End If

    Sub MapDrive
    Set WshNetwork = WScript.CreateObject(“WScript.Network”)
    Set objPassDlg = CreateObject(“PassDlg.LogonDialog”)
    Set objShell = CreateObject(“Shell.Application”)
    objPassDlg.Confirm = True
    objPassDlg.ShowDialog “Connecting to AUM’s Common Drive”
    If objPassDlg.Canceled Then
    ‘Wscript.Echo “Cancelled”
    WScript.quit
    Else
    WshNetwork.MapNetworkDrive sDriveLetter, “\x.x.x.xCommon”, False, objPassDlg.UserName, objPassDlg.Password
    objShell.NameSpace(sDriveLetter).Self.Name = sLabel
    WScript.Sleep(5000)
    Call DriveCheck

    End If
    End Sub

    Sub DriveCheck
    Set CheckDrive = WshNetwork.EnumNetworkDrives
    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”)
    Call Retry
    End If
    End Sub

    Sub Retry
    If MessageBox = 4 Then
    Call MapDrive
    If MessageBox = 2 Then
    WScript.Quit
    End if
    Else
    WScript.Quit
    End If
    End Sub[/CODE]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.