|
-
Sep 7th, 2012, 04:58 PM
#1
Thread Starter
Lively Member
[RESOLVED] programmatically restart app after end
My Idea (which may be not good) was to at form unload add....
Code:
Private Sub Form_Unload(Cancel As Integer)
Dim RetVal
RetVal = ShellExecute(vbNull, "open", App.Path & "\" & App.EXEName, vbNullString, vbNullString, 1)
End Sub
But it didn't work coz i check for app.previnstance in form load event and end it if i find one. And the above method works so fast that it loads the instance before the oriinal app has been unloaded so the app.previnstance gets true and ends.
Then my 2nd method was to let the 2nd opening instance app to wait a little bit for the original app to completely unload and i achived it using timer to wait a few seconds and then check for the instance, but ironically after few seconds when the timer gets activated even though the original app has been unloaded the app.previnstance gets true and the 2nd instance also gets ended????????
Does anybody has a solution?
PS: I don't want to use batch files or another app for restarting etc...
-
Sep 7th, 2012, 05:10 PM
#2
Re: programmatically restart app after end
Without giving any thought to your problem why don't you have two app? 0.exe and 1.exe. Both the same but different EXE names. Then Shell the opposite name of the one running by using XOR on the app name
Last edited by jmsrickland; Sep 7th, 2012 at 05:16 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Sep 7th, 2012, 05:25 PM
#3
Re: programmatically restart app after end
Why are you trying to restart it on end? Hopefully this is just some special case and not normal behaviour else the user would never be able to terminate your program using normal methods and may even have trouble shutting down or restarting thier machine. Doesn't seem like a very good idea. If I were to install a program that did this I will kill the process then delete the files from my system.
-
Sep 7th, 2012, 05:36 PM
#4
Thread Starter
Lively Member
Re: programmatically restart app after end
@jmsrickland it wont look nice for the user to see 2 copies ofyour app
@DataMiser it is very different situation
-
Sep 7th, 2012, 05:37 PM
#5
Thread Starter
Lively Member
Re: programmatically restart app after end
@jmsrickland it wont look nice for the user to see 2 copies ofyour app
@DataMiser it is very different situation
-
Sep 7th, 2012, 05:51 PM
#6
Re: programmatically restart app after end
 Originally Posted by ufo973
@jmsrickland it wont look nice for the user to see 2 copies ofyour app
@DataMiser it is very different situation
How will users see two copies? In the Task bar or on the screen? If on the screen then both copies look identical; if task bar then yes.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Sep 7th, 2012, 05:56 PM
#7
Re: programmatically restart app after end
You could put a switch to bypass app.previnstance when you go to load app the second time and load it before you enter the Unload event.
Dim AllowPrevInstance As Boolean
At startup
If Not AllowPrevInstance Then
'
' your code to check for app.previnstance
'
End If
Your code to load 2nd instance
Private Sub SomeSubRightBeforeUnload()
AllowPrevInstance = True
'
' Your code to load 2nd instance
'
End Sub
Last edited by jmsrickland; Sep 7th, 2012 at 06:05 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Sep 8th, 2012, 12:53 AM
#8
Fanatic Member
Re: programmatically restart app after end
-
Sep 8th, 2012, 04:21 AM
#9
Thread Starter
Lively Member
Re: programmatically restart app after end
 Originally Posted by coolcurrent4u
Thanks Alot it is what i wanted 
PS:How to mark a thread Resolved?
-
Sep 8th, 2012, 04:30 AM
#10
Re: programmatically restart app after end
 Originally Posted by ufo973
Thanks Alot it is what i wanted
PS:How to mark a thread Resolved?
At the top of the thread is the "Thread tools" menu. Select it then go to "Mark thread resolved".
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
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
|