Results 1 to 4 of 4

Thread: ShellAndWait and Checking for Hangs

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2007
    Posts
    29

    ShellAndWait and Checking for Hangs

    I am trying to use a shellandwait command on a net use batch file. However if the net use information is incorrect and it is asking for a password the cmd window will never close because it's waiting for input

    I have tried using timers but can't seem to place it right, anyone have any ideas on how to achieve what I am looking for?


  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: ShellAndWait and Checking for Hangs

    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2007
    Posts
    29

    Re: ShellAndWait and Checking for Hangs

    This is what I have now:

    Code:
    Private Function shellAndWait(ByVal fileName As String) As Long
        'Execute the application/file, but HIDE the window
        Timer1.Interval = 1000
        Timer1.Enabled = True
        glPid = Shell(fileName, vbNormalFocus)
        If glPid = 0 Then
            MsgBox "Could not start process", vbExclamation, "Error"
        End If
        
        If timercnt = 3 Then
            shellAndWait = glPid
            Timer1.Enabled = False
        End If
    End Function
    Private Sub Timer1_Timer()
        timercnt = timercnt + 1
        If timercnt = 2 Then
            Dim i As Long
            '
            ' Enumerate all parent windows for the process.
            '
            Call fEnumWindows
            '
            ' Send a close command to each parent window.
            ' The app may issue a close confirmation dialog
            ' depending on how it handles the WM_CLOSE message.
            '
            For i = 1 To colHandle.Count
                glHandle = colHandle.Item(i)
            Call SendMessage(glHandle, WM_CLOSE, 0&, 0&)
            Next
            MsgBox (glPid)
            ErrorCode = "30"
            ErrorStatus = 1
        End If
    End Sub
    But this is not working the way I want, basically the timer is checking to make sure that it doesn't wait too long, shellandwait will just sit there otherwise if Net Use is asking for a password

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: ShellAndWait and Checking for Hangs

    After your message box saying it can't start, put Timer1.Enabled = False and see if that helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width