From: Tony Toews [MVP] on 6 Oct 2009 18:44 Folks I'm going to be adding the ability to check for updates to my VB6 utility. Now you can't replace an exe while it's actually being used. Correct? I have had this happen to me a few times when I've been testing the exe in a Virtual PC session, have switched over to the VB IDE, fixed the bug, made a new exe and then haven't been able to replace the exe because it was in use. To me the most elegant way is to create a very small VB6 exe whose only job is to be called by the main VB 6 exe and to copy in the new exe and start up the main app again. Now I could muck about with creating a one line .cmd file with a copy line in it. But that, to me, just isn't all the elegant and is rather a brute force approach. Not that I mind brute force approach but the momentary flashing of the command prompt screen I find is rather disconcerting when I see some apps using it. Any suggestions? Or is a little stubbie program the best option? Tony -- Tony Toews, Microsoft Access MVP Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ Granite Fleet Manager http://www.granitefleet.com/
From: Tony Toews [MVP] on 6 Oct 2009 18:53 "Tony Toews [MVP]" <ttoews(a)telusplanet.net> wrote: >To me the most elegant way is to create a very small VB6 exe whose >only job is to be called by the main VB 6 exe and to copy in the new >exe and start up the main app again. Whoops. Let me rephrase that. Create a very small VB6 exe whose only job is to be called by the main VB 6 exe which then exits. Then the stubbie copies in the new exe, starts up the main VB6 exe again and exits. Tony -- Tony Toews, Microsoft Access MVP Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ Granite Fleet Manager http://www.granitefleet.com/
From: Karl E. Peterson on 6 Oct 2009 19:21 Tony Toews [MVP] wrote: > "Tony Toews [MVP]" <ttoews(a)telusplanet.net> wrote: > >>To me the most elegant way is to create a very small VB6 exe whose >>only job is to be called by the main VB 6 exe and to copy in the new >>exe and start up the main app again. > > Whoops. Let me rephrase that. > > Create a very small VB6 exe whose only job is to be called by the main > VB 6 exe which then exits. Then the stubbie copies in the new > exe, starts up the main VB6 exe again and exits. That seems to make sense, yeah. It'll simply need a method to detect whether the main app has shutdown. -- ..NET: It's About Trust! http://vfred.mvps.org
From: Eduardo on 6 Oct 2009 19:37 Tony Toews [MVP] escribi�: > "Tony Toews [MVP]" <ttoews(a)telusplanet.net> wrote: > >> To me the most elegant way is to create a very small VB6 exe whose >> only job is to be called by the main VB 6 exe and to copy in the new >> exe and start up the main app again. > > Whoops. Let me rephrase that. > > Create a very small VB6 exe whose only job is to be called by the main > VB 6 exe which then exits. Then the stubbie copies in the new > exe, starts up the main VB6 exe again and exits. > > Tony > I don't know how to judge something as elegant or not elegant, but you can replace an exe without the need of another exe if you want. It would work like this: 1) The exe (only exe) download the new version and save it to the temp folder. 2) Once finished downloading, is runs the new exe located at the temp folder and exits. 3) The temp exe wait until the other exe exits process, and then copy itself to that location with that name. 4) The temp exe then runs the updated exe and exits the process. 5) The new exe waits until the temp exe exits the process and then deletes it. You can intruct what to do in the command line parameters. Or, if you decide to ship another exe for that purpose (updating), it is even easier.
From: Eduardo on 6 Oct 2009 20:10
There are several things that you'll need to do whaterver method you use. One of these things is about the rights. You'll need to run as admin to do that on Vista. But if your program usually don't run as admin, you'll need to scale privilleges in order to do that. It is the "runas" option in the ShellExecute API for that purpose. But the "main" problem is that when you are done updating, you should come back to non provilleged execution mode, as normal user. And the API don't provide a direct way for doing that. Leaving the program running as admin could have consequences, because the folders are not wirualized, etc. I found a page that described a workaround for doing that, I'll see if I can find it again... Here is the article: http://www.codeproject.com/KB/vista-security/VistaElevator.aspx?msg=1922231 And this: http://www.codeproject.com/KB/vista-security/RunNonElevated.aspx Anyway, the source code is in C, but it may help. |