Uninstalling a service.

Got a problem you cannot solve? Try here.
Post Reply
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Uninstalling a service.

Post by bokkie »

Guys, forgive me if I'm being a dufus but I've experienced a problem in IA which I also get in IS. At this time I'm assuming it's because I'm doing the same things incorrectly in IA as I'm doing in IS so that maybe makes it my fault.

I have a service application say, A.exe. I created a project file for it and I add the A.exe into it. I then tried using the install service and control service options. When I build and run the package, the service file is installed correctly and it's also registered in the services management console. So far, so good. I can stop and start the service without a problem. Now, when I come to uninstall the package, everything is cleaned up and deleted successfully, but for some reason, the service is not unregistered from the SMC. As I say, I've experienced this problem before with IS but not all services we use experience this problem. If I try and start the rogue service registration, Windows tell me that the path to the executable does not exist which is fine so that proves it's uninstalling correctly. But for some reason I get orphaned registrations in the SMC which are not being culled.

Does anyone have any idea what it is I'm doing wrong or is this some kind of anomaly with the service registration/deregistration process? I don't think it's a problem with IS and IA but I'd appreciate any help or pointers.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

It might be an MSI issue if it occurs with both IS and IA. Sorry, I know that doesn't really help...we have worked around MSI issues before, so if you can find out more details, please keep us posted.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Post by bokkie »

MichaelNesmith wrote:It might be an MSI issue if it occurs with both IS and IA. Sorry, I know that doesn't really help...we have worked around MSI issues before, so if you can find out more details, please keep us posted.
Will do, Michael. I usually fix it by searching for all references to the service in the registry and then delete the keys it finds. A reboot is needed to finally remove it from the SMC.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

You can use Delete Registry in InstallAware after Apply Uninstall to automate part of that process, then.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
StyX
Posts: 51
Joined: Fri Apr 11, 2008 7:14 am
Location: Stavanger, Norway
Contact:

Post by StyX »

I've found that the easiest and most reliable way to remove services is through running a .bat file with the following content:

sc stop "The Service Name"
sc delete "The Service Name"

On Vista, Windows 7 and Server 2008 the .bat file execution needs to be elevated.
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Post by bokkie »

StyX wrote:I've found that the easiest and most reliable way to remove services is through running a .bat file with the following content:

sc stop "The Service Name"
sc delete "The Service Name"

On Vista, Windows 7 and Server 2008 the .bat file execution needs to be elevated.
styx, I've also done the same in the past myself but not necessarily inside my IS projects. I'm leaning towards Michael's explanation that there may be something inside the MSI that's flaky that IA have no control over. Now that I'm a bit wiser about that I'll adopt a more aggressive approach to uninstalling services. As I mentioned, not all services we uninstall in the same package experience this problem.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

Also please remember that its always a better idea to call programs directly instead of running batch files. For instance, if you are calling a program called sc.exe, always call that with Run Program (As) directly, instead of putting those statements inside a batch file. Batch files are not executable, and they are interpreted/run by cmd.exe, so this is two levels of indirection which introduces two possible points of failure - something you really don't need.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
tommykjensen
Posts: 29
Joined: Fri Jan 16, 2009 11:56 am
Location: Denmark
Contact:

Post by tommykjensen »

If its ok to ask here I have a related question.

I have a service application which can install and uninstall the service itself by calling either "app -install" or "app -uninstall". So I call the -install command after install and the -uninstall before uninstall. This works fine under normal conditions.

I have also configured webupdates which works fine except when the install runs it runs uninstall first but it does not run my program before uninstall so the service is not uninstalled which means that when the install continues with installing the service I get an error. For now I just set the program run after install to not wait for completion so the installation does not break. Its not a big problem but I will get questions about it from my users about this so it would be nice if I could get it solved.
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

In that case, you can use Run Program instead of (Un)Install MSI Setup to remove your old version product. That will also undo all your custom actions. You can read in the registry to find out where to run the setup program from based on the product code guid:
HKEY_LOCAL_MACHINE\\SOFTWARE\\MimarSinan\\InstallAware\\Ident.Cache\\{PRODUCT-CODE}
Read the default value here - that is the folder where setup.exe will be cached on the target system.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
jason
Posts: 4
Joined: Mon Feb 02, 2009 7:38 pm

Post by jason »

I did try both way that you guys mentioned. which is using the MSI code and delete registry but i fail to do so. is there any idea on this?

i did select "Delete Registry" and key i selected is the product code just like what mentioned by micheal.

And during my first try. i did make my window corrupted. :cry:
Post Reply