"End Task" a frozen application

I run a vb program that I created and it is vital that it runs smoothly. My program takes control of another program which downloads information from another location. It is done every morning before anybody is in the office.

Everything works fine except that about once a week the program that VB is controlling gets timed out and is frozen. The only way to restart it is to "End Task".

The way I see it there are 2 options:(I am open to any options though)

1.Have multiple versions of the program running.
This would work except that I do not know how to refer to more than one instance of this program. Does Windows provide a way for Visual Basic to do this. If I run the VB code, it tries to perform the operations on the first version opened. If there was a way to loop through all the open applications and find the next instance, that would be great!

2. Use a command similar to "End Task" and terminate the program. The whole process should not take more than 45 minutes.The program that I control has no error handling (which is just great). But I could run a version of the VB program every hour starting at 3 AM until it runs successfully.I would then be able to open a new version of the program and continue the operations.

Thanks to anybody who took the time to read this!

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Could we see the code for "controlling" the other program?
what about if you write a another program, which calls this VB program everyday and closes it after a certain period.  This way, you don't have to worry about running multiple instances of the VB program, run the startup program with hardcoded timining options.
Determine if an Application has Stopped Responding and terminate if it has:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vbaRookieAuthor Commented:
Here is the code for the program:

Private Sub QueriesToRun()

Dim acc As Access.Application
Dim rst As DAO.Recordset
Dim objApp As Object
Dim DataMdl As Object
Dim Dwindow As Object
Dim PromptDate As Object
Dim DWbutton As Object
Dim SatDate As Date
Dim FriDate As Date
Dim fTextFile As TextStream
Dim fFile As File
Dim fSysObject As FileSystemObject
Dim rstPrompts As DAO.Recordset
Dim rstQry As DAO.Recordset

On Error GoTo ErrorHandler:

Set objApp = GetObject(, "Query.UpDate.Application")
'take control of the open application
'this is the part that I need help on

Set DataMdl = objApp.DataModel
'sets the open data model to the object
objApp.Visible = True

Set acc = New Access.Application
acc.OpenCurrentDatabase "H:\data\Scheduler\Scheduler.mdb"
'loop through an Access table of queries to run,along with
'the properties needed for it to run
''''''''''''''''''''''''''''''''''start loop
Set rstPrompts = acc.CurrentDb.TableDefs("tblDWPrompts").OpenRecordset
Do Until rstPrompts.EOF = True
Set PromptDate = DataMdl.Prompts(rstPrompts.Fields("strPRMTPromptName").Value)
Set rstQry = acc.CurrentDb.QueryDefs(rstPrompts.Fields("strPRMTQueryToFindPrompt").Value).OpenRecordset
PromptDate.Confirm = False
PromptDate.AddValue (rstQry.Fields(rstPrompts.Fields("strPRMTQueryFieldName").Value))
Me.lstStatus.AddItem PromptDate.Name & "'s value is " & rstQry.Fields(rstPrompts.Fields("strPRMTQueryFieldName").Value)

'''''''''''''''''''''''''''''''''''start loop
Set rst = acc.CurrentDb.TableDefs("tblScheduleTasks").OpenRecordset

Do Until rst.EOF = True
Set fSysObject = New FileSystemObject
Set fFile = fSysObject.GetFile("H:\Data\Reports\QRD\" & Trim(rst.Fields("strDWQrdName")))
'set to look at each qrd

If Format(fFile.DateLastModified, "Short Date") <> Format(Date, "Short Date") Then
'logic to see if it has been run

Set Dwindow = DataMdl.Windows(Trim(rst.Fields("strDWWindowOnDW")))

'the following is the code to run the Query Program


Set DWbutton = Dwindow.Buttons(Trim(rst.Fields("strDWButtonOnDW")))
lstStatus.AddItem DWbutton.Name & " OK at " & Time
FileCopyToNetwork Trim(rst.Fields("strDWQrdName"))

End If
rst.MoveNext 'move to the next record in the table

Exit Sub

MsgBox "objApp ERROR " & Err.Number & Err.Description
End Sub
I hope that was not too much code, only the first part with the GetObject is very important to this question.
I hope this helps

The program opens from a command line like this
"C:\Program Files\Query\update.exe" "R:\Query\OnDemand\OnDemandIBM.gqu"
Both must be run in order for the program to function properly. I am able to use the shell function to open it, but I still can't differentiate which Query Application to take control of. When the first one "freezes" I am stuck.
vbaRookieAuthor Commented:
Thank you very much, I was able to take what I needed out of the source code. Thanks to everybody who helped!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.