Shutdown

  • Thread starter Thread starter Thom Little
  • Start date Start date
T

Thom Little

I have a Winform application that is always running.

If this application is to be revised I need to shut down the current
version, install the new version, and the start the new version.

Is there a recommended approach for the installer to request a shutdown and
for the executing program to act on that request?
 
Hello Thom,
The .NET way would be to use this application block,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/updater.asp

you won't have to shutdown the app. with this method. Yes there is a way to do what you want, but that will take more work, you'll have to work with the Windows Installer SDK.

Best of luck!
RBischoff , your C# ally

TL> I have a Winform application that is always running.
TL>
TL> If this application is to be revised I need to shut down the current
TL> version, install the new version, and the start the new version.
TL>
TL> Is there a recommended approach for the installer to request a
TL> shutdown and for the executing program to act on that request?
TL>
 
Thank you. What I was hoping for was a lead on the MSI/.NET approach to the
task.

Can you suggest any examples, articles, or posts that illustrate the
approach?
 
Have you concidered to create your application as a windows service instead?

Torben
 
Yes but my application resides in the System Tray and the user must interact
with it.

It is currently implemented with the Installer checking to see if the
application is running. If it is the installer emits a dialog telling the
user to shut down the running application and hit a continue button in the
dialog. The installer will not proceed until the user has manually shut
down the running application.

What I want to do is simply signal the running application to shut down and
then have the running application shut itself down.

Any ideas?
 
Use System.Diagnostics.Process.GetProcessesByName or itterate through
System.Diagnostics.Process.GetProcesses.

FYI, I have done this before, not sure how "supported" it is, but try to
rename the exe, install the new exe, then restart the app.

You could always open a remoting channel to the process as well.


This advise is probably a little unstandard, but it may give you some ideas.
 
Your alternative approach still requires user intervention.

I currently create an array of processes using Get ProcessByName and if
there are any entries in the table I put out the message to manually
shutdown the running process.

My "dumb as dirt" question is ... how do I shutdown the running process
identified in the table without involving the user?
 
You can also send the close command to the main window. (probably cleaner)
System.Diagnostics.Process.GetProcesses()[0].CloseMainWindow

Or you can kill the process...
System.Diagnostics.Process.GetProcesses()[0].Kill

*** Please do not use the 0th process it's only an example, but once you
found your process just use .CloseMainWindow or .Kill
 
That did the trick ... almost.

Since this is a system tray application there is an icon in the system tray.
When the CloseMainWindow is processed the icon is left in the system tray.
When the Kill is processed instead the icon is removed.

This seems to me to be a "a devil's playground" for hackers.

Thank you for the help.

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Ron Barone said:
You can also send the close command to the main window. (probably cleaner)
System.Diagnostics.Process.GetProcesses()[0].CloseMainWindow

Or you can kill the process...
System.Diagnostics.Process.GetProcesses()[0].Kill

*** Please do not use the 0th process it's only an example, but once you
found your process just use .CloseMainWindow or .Kill




Thom Little said:
Your alternative approach still requires user intervention.

I currently create an array of processes using Get ProcessByName and if
there are any entries in the table I put out the message to manually
shutdown the running process.

My "dumb as dirt" question is ... how do I shutdown the running process
identified in the table without involving the user?
 
Back
Top