Service not removed after uninstall the application - visual-studio

I have created the setup of window form application using visual studio setup project.
It install fine and works fine my application.
But when i uninstall the application it uninstall properly without any error, but the service of the application does not remove from services.
I don't know why this happens.
Please somebody help me. thank you in advance.

I have a same issue in my application.
I just add the window restart code in installer class, so when i uninstall the application system restarts and application process & service both have removed.

There are a few possible reasons for this:
You did not add your installer class to every node of the custom actions list in your setup project. In other words, maybe there is no uninstall custom action so the service won't be uninstalled.
If there is an uninstall method, it will typically not stop your service unless you do that, by adding shutdown code to an override, before base.Uninstall(). That means it will attempt to uninstall it, probably mark it as Disabled in the services applet and remove it at the next reboot.
You might be using Installer classes (without using custom actions) and trying to run InstallUtil.exe. This is not the right way to do it, but if you didn't run it as uninstall custom action then you haven't uninstalled, and number 2 still applies. Finding InstallUtil.exe to do this is not safe anyway.
Having said that you still haven't been explicit about how you used installer classes, if they are custom actions, or if you're running InstallUtil.exe, if there is an uninstall custom action, and what is the exact state of the service after the uninstall.

Related

How to get MSI Installer to run some code on uninstall of a service

I'm having troubles with some could I would like to execute when the service will be uninstalled. I've added the code to both the System.ServiceProcess.ServiceProcessInstaller BeforeUninstall event, and
to the override method OnBeforeUninstall, but that did not work too.
When using my InstallShield msi to uninstall the service this code does not get executed.
How can I force the service to launch some code during uninstall? Do I need to use a different event in my C# service? Do I need to change something in my MSI?
Note:
My problem is identical to the following
https://community.flexerasoftware.com/showthread.php?149176-MSI-Uninstall-NET-Service-does-not-launch-BeforeUninstall-event
Thanks,
sagar
You'll need to be more explicit about everything you've done. For example there is no automatic calling of installer class methods unless they are explicitly added to your setup as custom actions (in your case an uninstall custom action). You should also explain exactly how the service was installed.
Note that installer classes were invented by Visual Studio setups, and there is typically no need to use them because tools like InstallShield usually support the standard ServiceInstall and ServiceControl functionality in Windows Installer. Installer classes are unnecessary. Also, those events are Visual Studio specials, and it's not clear to me if InstallShield supports them. If you are using an Uninstall method to uninstall a service then just add your "before" code to before the Base.Uninstall() call.
If you want code to run when the service is uninstalled, the more usual way is to have a custom action that calls your code, and condition the call on REMOVE="ALL" (for an uninstall) or other conditions depending on your exact requirement. For example, if you do an upgrade MSI to upgrade your existing product do you still want to run that uninstall code?
.NET Installer Class: PhilDW has already said it all, but I just want to add a couple of things. I assume you are using System.Configuration.Install.Installer and the ServiceProcessInstaller Class (there is a sample in the Installshield help file). There used to be (and I think there still is) a flag for each Installshield component called .NET Installer Class. You can set this flag to Yes, and then I believe Installshield itself will take care of running your installer class methods (Install, Commit, Rollback, Uninstall - whichever one is implemented I think, but I have never tested all scenarios. I don't use this feature).
InstallUtil.exe: Running InstallUtil.exe would indeed call these methods. I am not sure how Installshield calls the methods under the hood (during setup execution) - they may actually be calling InstallUtil.exe for all I know, or some more low-level API call.
Conclusion: Just go to the components view and click on the component containing your service.exe file - and set the flag mentioned above. The exe must be a key-file for the component in question - and it must be a .NET assembly. Like PhilDW wrote, I wouldn't use these methods since they are intended to be used during service development only - not during deployment. For one thing you could run into runtime errors when the methods try to run faulting your whole setup (and often unnecessarily so), and there are also likely issues with rollback and potentially other problems. Can we ask what the methods are actually doing? Perhaps you are just deleting some log files? There are other ways to do that - most significantly using the RemoveFile table.

How to create installer for WCF service,which is created in Visual Studio 2012(.net framework 4.5)?

I need to create installer package for WCF(service) class library,which i created in VS2012 with .net framework 4.5.
2.I try to install the service manually using VS2012 command prompt with the following link, http://www.youtube.com/watch?v=vTPCWrZedKI
Actually it put entry in Window services, when i try to start the service manually i am getting an error like "The service on local computer started and then stopped,Some services stop automatically if they are not in use by other services or programs.
I tried to fix those errors by changing to local system account and clearing the evenlog,
but nothing works fine for me.
I tried it using Advance installer by providing the dll file in Services tab,but it fails to start the service getting an error like "Verify that you have sufficient privileges to start the stystem sevices".
Please tell me how can i proceed further?
I don't need to use third party softwares like wix for creating installer package.
*Is there any way to achieve this task. If so please guide me and give me a sample application to achieve this task.*
I am spending more than 10 days for this task..
Awaiting for your repliessss!!!
Regards,
Lokesh.J

How to prevent running multiple instances of setup.exe created in installshield basic msi project?

I have created my application's setup in installshield - basic MSI project...
Now when i am installing it, it allows me to run .exe multiple times simultanious...
Please let me know, how can i stop it.....
There is already a safe guard automatically built-into Windows Installer. If two or more of your installs actually try to install only the first one will install. The others will throw a message saying another install is already in progress. This is enforced by the _msiexecute mutex.
If you want to gate the situation earlier, you'll have to write your own custom actions to create your own custom mutex, tear it down when the install is complete and check for it when starting the install. However, I'd mark this problem as Functions as Designed and move on.

Windows Service Setup Project

I’m trying to create a set-up project for a windows service. I’ve followed this tutorial and many others like it but, after installing my service, I still can’t see the service. I’ve added the primary output of the service to the application directory and created a custom action to include this output on Install, Commit, Rollback and Uninstall.
It claims that it installs correctly.
Should this work? Is there anything else that I can try to get this to install?
Did you create an installer for your service? It is separate from a Setup Project.
See: http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.aspx
You can create an Installer by right-clicking on your service's Design window and selecting Add Installer.
In my case, adding the installer was a first step as described by dhirschl's answer. I then needed to add custom actions to the setup project.
Right click the setup project/view/custom actions
then add the primary output to every folder there.
Source

Run another installer in an Inno Setup installation

My company is developing an application that has a dependency on another of our applications. That second application already has an Inno Setup installer.
So I think I'd like to bundle the second application's installer within the Inno Setup installer for the first application. But I'm not sure how to go about that properly. Does anyone know the "right way" to do this?
I found this: Inno Setup Knowledge Base—HOWTO: Install .MSI files. I assume the technique could be used for a nested Inno Setup installer. But I have a couple of questions about the fine details:
How could I make it so if the first application is uninstalled, the second is also uninstalled?
Is that a sensible thing to do (automatically uninstall the second application), or should I leave it to the user to do that manually?
If the user tries to uninstall the second application while the first is uninstalled, should I somehow detect that and give a warning? How could I do that?
For the level of uninstaller functionality you are talking about, I suggest you get familiar with pascal scripting in Inno Setup (if you are not already). It offers incredible customisation, but has the caveat of making your projects a lot more complex.
To answer your third question first:
Yes, you should do this. In order to do it properly, you need to add this functionality to the uninstaller of the second application (i.e. the one your app is dependent on). See Uninstall event functions in the Inno Setup help. You need to check in that uninstaller if your app is installed (by checking if HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SecondAppName exists, for example) and in that case show an additional warning.
As for your second question:
If it is remotely possible that your customer wants to continue using the second app, even if he decides that he wants to uninstall the first one, you should offer him the choice. I would do this with a seperate wizard page in the uninstaller for your app, after your app is uninstalled.
And finally, your first question:
You need to determine the name (full path) of the other app's uninstaller exe. You can retrieve it from the registry key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SecondAppName\UninstallString. For executing it from a script in the [CODE] section, see Exec in the Inno Setup help.

Resources