Uninstall - Target Still Running?

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

Thom Little

During an uninstall, how can I check to see if the application I an
uninstalling is currently running?
 
Hi Thom,

Based on my understanding, you want to un-install an application, so you
want to know whether an application is running before un-install.

================================
You can refer to System.Diagnostics namespace.

You can use Process.GetProcessesByName method to return a list of running
processes, whoes name is your application.

If you can not determine your application's name, I think you may use
Process.GetProcesses method to get all the processes current running. Then
for each process, you may use Process.MainModule.FileName to get the
process's main module's full file path.(You can compare this with your
application's path to determine if it is your application's process)

===============================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
You unfortunately answered the question I asked and not the question I
thought I asked ...

Is there a way to shutdown the running task after you have identified it or
are you restricted to "tell the user to shut it down and exit the
uninstall"?

My assumption is that there is no way to shut it down.
 
Hi Thom,

Thanks very much for your feedback.

If you have determined the process is running now, the normal way is notify
the user that the application is going to be un-installed, and letting the
user to close it properly.

You also may use Process.Kill method to terminate it yourself, but data
edited by the process or resources allocated to the process can be lost. So
it is not recommanded to use this way.

All in all, you should use your second option.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Thom,

Does my reply make sense to you? Do you still have any concern on this
issue?

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
It ALMOST does. What came up with was ...

using System ;
using System.Windows.Forms ;
using System.Diagnostics ;

namespace ThomLittleAssociates
{
public class tlaSystemTrayDetect
{
public static void Main( string[] args )
{
for ( ; ; )
{
Process[] procMain = Process.GetProcessesByName(
"tlaSystemTray" );
if ( procMain.Length > 0 )
MessageBox.Show( "Your system is currently running
tlaSystemTray.\nRight-clicktlaSystemTray and select Exit.\nThen respond OK
to this message.", "tlaSystemTray" );
else
break ;
}
}
}
}

.... and this works fine when added as a custom action to uninstall.

The only problem is that it displays an empty command line window as it
runs.

My NEXT dumb question is how do I get rid of the bogus command line window?
 
I found it ...

I needed to change the Output Type for this class to Windows Application.

The uninstall is now running correctly and it will sit in the loop waiting
for all occurrences of the application to be removed.

It is really strange that two standard dialogs are not present in the MSI
....

1. Start this application after installation.
2. Shut down this application if running during uninstall.

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

Thom Little said:
It ALMOST does. What came up with was ...

using System ;
using System.Windows.Forms ;
using System.Diagnostics ;

namespace ThomLittleAssociates
{
public class tlaSystemTrayDetect
{
public static void Main( string[] args )
{
for ( ; ; )
{
Process[] procMain = Process.GetProcessesByName(
"tlaSystemTray" );
if ( procMain.Length > 0 )
MessageBox.Show( "Your system is currently running
tlaSystemTray.\nRight-clicktlaSystemTray and select Exit.\nThen respond OK
to this message.", "tlaSystemTray" );
else
break ;
}
}
}
}

... and this works fine when added as a custom action to uninstall.

The only problem is that it displays an empty command line window as it
runs.

My NEXT dumb question is how do I get rid of the bogus command line window?

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

"Jeffrey Tan[MSFT]" said:
Hi Thom,

Does my reply make sense to you? Do you still have any concern on this
issue?

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Thom,

I think the dialog for "Shut down this application if running during
uninstall" does exisit but the wording is a little bit different.

The dialogs in MSI are quite different from the dialogs in WinForm
applications. We have the option to author our customized MSI dialogs,
either through VS.Net Setup project, or through Windows Installer Platform
SDK.

If you need any further assistance on MSI issues, please feel free to post
under "microsoft.public.platformsdk.msi".

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I searched rather aggressively with no luck. If dialogs for ...

1. Start this application after installation.
2. Shut down this application if running during uninstall.

.... exist in the MSI their location is the best kept secret in Visual Studio
..NET 2003.

Do you have a suggested information source?
--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Felix Wang said:
Hi Thom,

I think the dialog for "Shut down this application if running during
uninstall" does exisit but the wording is a little bit different.

The dialogsI looked rather agressibely and if ...Setup project, or
through Windows Installer Platform
 
Hi Thom,

Thanks for your update. The "2. Shut down this application if running
during uninstall." dialog is not shown in VS.Net. If we open the MSI
generated by Setup project with Windows Installer Platform SDK tool "Orca",
we can see there is a dialog named "FilesInUse", which contains the
following "Text" control:

The following applications are using files which the installer must update.
You can either close the applications and click "Try Again", or click
"Continue" so that the installer continues the installation, and replaces
these files when your system restarts.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Thom,

Does my colleague's reply make sense to you? Do you still have any concern
on this issue?

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I don't know what to do with the information. I wrote a custom xxx that
sits in a loop displaying a MessageBox and you must shut the application
down.

How do I get Orca and how does it relate to the MSI setup that I have
created?
 
Hi Thom,

Thanks for your update.

Generally speaking, Windows Installer has the capability to detect that
files are in use by itself. As a result, it will display the dialog I
mentioned to warn the customer before the uninstallation actually starts.
If we ignore the warning and keep the file opened, Windows Installer will
prompt us for reboot after the uninstallation. After the reboot, it will
remove the in-use file. Generally we do not need to worry too much about
the point.

As far as Orca is concerned, it is a Windows Installer Platform SDK tool:

HOWTO: Use the Orca Database Editor to Edit Windows Installer Files
http://support.microsoft.com/?id=255905

If you need any assistance on Windows Installer, please feel free to post
under microsoft.public.platformsdk.msi.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Great ... almost ...

I installed the SDK and ran Orca and pointed it at my .msi file. The dialog
that you referred to is present in the Dialog Viewer and apparently sitting
in my MSI file.

What's the "trick" to enable the display of the dialog?
 
Hi Thom,

You can use the menu "Tools" | "Dialog Preview" ;-)

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Thank you for pointing out that I was being less than clear.

Yes you can display the dialog box in Orca using Tools | Dialog Preview...

The question I was trying to ask is how do I trigger the display of the
dialog box at install time and uninstall time when the other dialog boxes
are presented?
 
Hi Thome,

The "FilesInUse" dialog is takend care of by Windows Installer. We don't
need to display it explicitly:

FilesInUse Dialog
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/f
ilesinuse_dialog.asp?frame=true

If you would like to show it, we can modify the "ControlEvent" table and
hook a button with "SpawnDialog" event to show it.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
If you would like to show it, we can modify the "ControlEvent" table and
hook a button with "SpawnDialog" event to show it.

I would indeed like to show it when appropriate during an install and during
an uninstall.

How the tables are manipulated in Orca control this process is not obvious
to me and it is apparently obvious to you.
hook a button with "Spawn Dialog"

Which button?
What conditions?

I am coming from a MSI environment and was surprised that this capability
was not in MSI. I wrote my own version. I was told it was already there
and just not enabled so what I developed was redundant. All I am trying to
do is enable an option that should have been in MSI in the first place using
a tool that was installed after installing the SDK.

I wonder what application I could come up with that would use MSI that would
not want to check for an executing copy of the application and give the user
the opportunity to shut it down.

Any "baby steps" you can provide in the use of Orca to perform this
apparently trivial task would be greatly appreciated/
 
Hi Thom,

As I mentioned, the dialog will be shown automatically if Windows Installer
detects the file is in use. We don't need to worry about it.

In addition, it is not an easy task to modify the user interface with Orca
directly. It needs comprehensive understanding on how MSI works:

User Interface
http://msdn.microsoft.com/library/?url=/library/en-us/msi/setup/user_interfa
ce.asp?frame=true

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Felix,

I am using MSI and the dialog in question is never automatically displayed.
This is the whole purpose of starting this quest.

My assumption is (from your previous instructions) that when using Orca I
can change the .msi file to enable it to automatically generate the dialog
at install and uninstall time when needed.

This enabling is the only thing I am attempting to do with Orca (in
accordance with your previous instructions).

How do enable the behavior of (1) detect if a specific program is in
execution (2) if not in execution do nothing (3) if in execution display the
dialog with three options?

Please help.

Regards,

Thom Little
 
Back
Top