|
-
May 20th, 2007, 11:59 PM
#1
Thread Starter
Junior Member
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?
-
May 21st, 2007, 12:44 AM
#2
Re: ShellAndWait and Checking for Hangs
Please mark you thread resolved using the Thread Tools as shown
-
May 22nd, 2007, 12:13 PM
#3
Thread Starter
Junior Member
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
-
May 22nd, 2007, 12:17 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|