Re: Problem with shell and termination

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ray Cox (notcoxmr_at_earthlink.net)
Date: 04/29/04


Date: Thu, 29 Apr 2004 04:05:09 GMT

This text is for kpg, since an interest was shown in this problem:

Since it seems that WinXP will not let even the TerminateProcess API act on
a VB program from which another was shelled (I have even tried to use this
by identifying the ThunderRT6Main "window" and it still doesn't work) I have
decided to try another method to get this process done.

Since you indicated an interest in this problem in the vb.winapi news group,
I'll describe my process in outline form below.

Let's assume that you have a main app "MyMain" and an upgrade app
"MyUpgrade" that you are going to use to upgrade the "MyMain" app when
appropriate. Instead of trying to start MyUpgrade from MyMain and then
attempting to shut down MyMain so it can be upgraded, I am going to try to
add a switching program to the mix - "MySwitch".

Whenever the main program is started, what will actually be started will be
the MySwitch program. This will be a very small program which will function
only to switch between the MyMain and MyUpgrade programs. The following
things can happen using the MySwitch program:

ToRunNormalApplication:
  Start program MySwitch
  MySwitch will (shell) start MyMain (passing Command$ parameters if
applicable)
  MyMain is shut down - passes control back to MySwitch
  Without Flags to start upgrade process, MySwitch shuts down and program
terminate is complete

ToRunNormalApplicationAndUpgrade:
  Start program MySwitch
  MySwitch will (shell) start MyMain (passing Command$ parameters if
applicable)
  Upgrade process is initiated in MyMain, setting Flags to start upgrade
process
  MyMain is shut down as part of upgrade process - passes control back to
MySwitch
  MySwitch sees Flags for Upgrade process and starts MyUpgrade
  MyUpgrade completes all installation of MyMain, as MyMain is certainly not
running now!
  MyUpgrade sets Flags for restart of MyMain and shuts down - passes control
back to MySwitch
   IF MySwitch sees Flags to restart MyMain THEN
      upgraded MyMain is restarted
   ELSE
      MySwitch is shut down and
   ENDIF

Since all shelling is done by the MySwitch program, it won't matter if the
MySwitch program is frozen/suspended until that particular shelled program
is terminated, as only one shelled program will be run at a time anyway.

If any of the VB support files are updated (additional service packs, etc.)
then this process still won't work, as even the MySwitch and MyUpgrade
programs will be using the msvbvm60.dll file (and possibly other components)
when attempts are made to upgrade. The solution I see here is to set the
RunOnce Registry entry with a batch/script/upgrade file to run and reboot,
allowing the PDW or your favorite install program to do the work without any
VB components being in use.

I don't know if this will help with your problem, but I wanted to allow my
users to be able to easily check for, download, and install upgrades
automatically with a single click.

Ray Cox

"Stefan Berglund" <keepit@in.thegroups> wrote in message
news:vq5s701si306lb8079vlq2m9rojhmi2n50@4ax.com...
> On Wed, 14 Apr 2004 20:47:52 GMT, "Ray Cox"
> <notcoxmr@earthlink.net> wrote:
> in <Yrhfc.6905$l75.4451@newsread2.news.atl.earthlink.net>
>
> >This is a problem I have not found a solution for in extensive web
> >searching. I am writing an automatic upgrade process for a VB6 app which
> >will (hopefully) automatically download and install upgrades to the app.
> >The main app handles everything through the download, then Shells to an
> >upgrade app which runs the setup routine for the actual install of the
> >upgrade.
> >
> >The problem comes in that after using Shell to open the upgrade app, the
> >original app is merely suspended instead of terminating as per the
internal
> >code which follows the Shell call to start the upgrade app. Then, the
> >setup/upgrade process in program #2 is foiled because the exe (#1) which
I
> >am trying to upgrade is "still running."
> >
> >I have considered the use of ExitProcess or TerminateProcess in the
upgrade
> >program (#2) to kill the original app (#1), but have read in places that
> >it's "not nice" (i.e. possible system problems) to terminate VB apps in
ways
> >that aren't handled directly via the run-time library code.
> >
> >Can anyone provide a method to start another program, then end/completely
> >close out/unload the original, calling program?
> >
> >This would actually need to be done twice...the first time to start the
> >upgrade program and shut down the calling program so it can be updated,
then
> >once all indications are that the upgrade process was successful, restart
> >the original, updated application (from the upgrade app) and shut down
the
> >upgrade app.
> >
> >If you reply to me personally, please remove the "not" from the front of
my
> >email address for correct processing, otherwise I will hawk the newsgroup
> >for any appreciated reply.
> >
> >Thanks,
> >
> >Ray Cox
> >
>
> Think of this as pseudo code:
>
> Dim strMain As String
> strMain = AppPath(App.Path) & "ShowTime.exe"
> If (FileExists(strSource & "ShowTime.exe")) Then
> Do While (FileExists(strMain))
> KillFile strMain
> DoEvents
> Loop
> CopyFile strSource & "ShowTime.exe", strMain, 0&
> ShellExecute 0&, "Open", strMain, "", App.Path,
> SW_SHOWNORMAL
> End If
>
>
> The above code is the auxiliary app. The main program downloads
> the update and then shells to the auxiliary app and exits. The
> auxiliary app then loops until it can delete the main app, copies
> in the replacement, and then starts up the replacement.
>
>
> ---
> Stefan Berglund
> first shift-minus last a t m s n d o t c o m



Relevant Pages

  • Re: Deploying new app. Upgrade theory
    ... such as why is there no Controls collection in a Ribbon ... my A97 app, I had one mainmenu form, with one submenu form. ... to your invitation to do the upgrade for free. ... Upon launching the app, if I detect that the database is blank, ...
    (comp.databases.ms-access)
  • Re: Deploying new app. Upgrade theory
    ... whenever you hit errors in your code, the global ribbon variable is lost, ... my A97 app, I had one mainmenu form, with one submenu form. ... to your invitation to do the upgrade for free. ... Upon launching the app, if I detect that the database is blank, ...
    (comp.databases.ms-access)
  • Re: Problems that can ocuur while upgrading from 9i 1o 10g
    ... I just completed one this weekend (plus a hardware change and app ... Since the app upgrade part of this was very involved, ... is different, Oracle uses memory granules, so you wind ...
    (comp.databases.oracle.server)
  • Re: non data ware grid?
    ... >> these days is custom accounting packages. ... > This app is maybe 30 forms and very simple gui. ... upgrade. ... > Doing palm programming really changed my whole approach to development. ...
    (borland.public.delphi.thirdpartytools.general)