Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Annoying Terminal Services program error

Status
Not open for further replies.

royalcheese

Technical User
Dec 5, 2005
111
GB
Hi All

I have a EXE file which users can use from home , via terminal services , Which works every other time you connect to it via Remote Desktop Connection. The message you get when it doesnt work is as such :

The system cannot fint the path specified
This initial program cannot be started : (My program path)
Please Check the initial program in the client configuaration.

Which leads me to believe that the program is not closing properly on it exit..

This is the code i have on the exit button click
Code:
Private Sub MDIExit_Click()
Call removelogrecord ' calls function to log out user

Dim f As Form
For Each f In Forms
Unload f
Set f = Nothing
Next f

End Sub

Once the system is closed and all visible functions have shut down then terminal services stays open which leads me to believe that it is still there, as normally when you shut all programs down it slef closes the RDC ?

Any help / Suggestions would be grand

Thanks in Advance

Chris
 
Are not resetting the f variable when calling set f = nothing?

Maybe try with just a next instead of next f?

JaG

yosherrs.gif

[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
Try adding some logging to the queryUnload, Unload anf terminate events of each form. This will show you that the forms are or are not being unloaded.

Likewise, usually the code you have posted is posted in the query_unload event. This means that is is run however the user closes the form. In the abouve instance the code will only run if teh user clicks the triggers the mdiexit_click event (I assume this is a button?)

Try something like
Code:
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
 'You can also test if user really wants to exit
 '
Cancel = 0
debug.print "about to unload main mdi form"
Call removelogrecord ' calls function to log out user

Dim f As Form
For Each f In Forms
Unload f
Set f = Nothing
Next f

debug.print "Forms loaded now = "; forms.count
End Sub

Private Sub MDIExit_Click()

Unload me
end sub

It may be that people are closing the program in a different way. This will catch that

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Hi Thanks for your suggestions , I have tried them and they dont help still sits there on exit.

Is there any way to absolutely kill every last form ? and everything ever and close the whole thing down ?
 
Do you get a log entry for each form queryunload and terminate event?

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
This may help:

Code:
Option Explicit

' [URL unfurl="true"]http://www.vbforums.com/showpost.php?p=2267518&postcount=4[/URL]
' by Pnish

Dim AllowUnload As Boolean

Private Sub MDIForm_Load()
    Form1.Show
    Form2.Show
    Form3.Show
End Sub

Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If UnloadMode = vbFormControlMenu Then
        AllowUnload = True
    End If
End Sub

Private Sub MDIForm_Unload(Cancel As Integer)
    If AllowUnload Then
        Exit Sub
    End If
        Cancel = True
    AllowUnload = True
End Sub

Private Sub mnuClose_Click()
    AllowUnload = False
    Unload Me
End Sub

Private Sub mnuExit_Click()
    AllowUnload = True
    Unload Me
End Sub

-David
2006 Microsoft Most Valueable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
<Maybe try with just a next instead of next f?
These are identical.

The only reason that I'm aware of to use the QueryUnload event instead of the Unload event is so you can evaluate the means by which the user is unloading the form. If this isn't necessary (if you don't need to do different things when the user unloads differently), then I would use the Unload event.

Bob
 
There is one other subtle difference between QueryUnload and Unload (although this is probably not relevant for the problem being discussed here) which is that - and I quote - "the QueryUnload event occurs in all forms before any are unloaded, and the Unload event occurs as each form is unloaded."
 
Hmm, that's a little odd. Strongm, are you aware of any unloading process that has begun at the point that the cancel flag is encountered, and therefore has to be reloaded again? That would be interesting to know.

Thx

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top