I need to reinstall my Windows service from same service. And installable version can be a previous version, so RemovePreviousVersion flag in setup project not going to work.
If I start the uninstall process from same service, my service will be stopped, and I can't to start another process to install desired version.
Is there any other way other than creating bat-file to uninstall and install required version from it?
Related
I have a .Net 5 console application that I am trying to run as a Windows service. I have followed all of the articles online on how to do this and have it completed successfully (ie: using BackgroundService). The question is, I want to have an MSI installer to deploy this and all of the articles I have read about creating a service in .Net 5 instruct me to install the service manually using a command prompt or power shell and issuing the "sc" command.
Back before .Net 5, I could use the built in Visual Studio Installer extension and simply create an MSI that would deploy and install my service. I can't seem to make that work for .Net 5.
Is it still possible to use the built in Installer extension to deploy and install my .Net 5 BackgroundService?
Thanks!
Installing Services: There are many ways to install services, you should use an MSI package and the built-in mechanisms there to install and start the service and stop and update it during upgrades.
Various ways to install services (with links to samples on how to install services using MSI).
Learning WiX: Please see the WiX section here - the links should get you started. Direct link to the main WiX link list.
Links:
Windows Services Frequently Asked Questions (FAQ)
Installation package created with WIX Toolset does not remove program folder + files on uninstallation
How to install a system service without permission errors
There is one windows service which is installed on one of our servers and working fine.
I tried to replicate the same on the other server, so I took the exe setup from one server to another and tried to install the windows service using installUtil.exe
It is giving me
The Commit phase was completed successfully. The transacted install has been completed.
but the service cannot be found in the services list and it is also giving me this message at the time of installation.
No public installers with the RunInstallerAttribute.Yes, the attribute could be found in the xyz.exe assembly.
Remove InstallState file because there are no installers.
and I am not sure why this is happening? I tried googling but most of them have given the solution to add installer to the project.
But if the installer is not added how the service is running on the first server
is there another way to install the service?
Could it be related to the Windows OS version?
When you install Windows Service via the wizard (using .msi file), Windows will add a record in Add or remove programs with a version number, that you can set in properties of the Wizard project.
You can also install Windows Service, using Sc.exe tool.
My question is, how to install windows service via Sc.exe tool and still have a record in Add or remove programs with a version. So I know what version of Windows Service is running. Ideal scenario would be to include the version in the code. So that Sc.exe will call MyService.exe without any parameters.
Thanks for help,
I am using MSI installer to upgrade my service from one version to another in Windows 7 and in windows server. The upgrade in windows 7 machine is working fine but it is failing in Windows Server 2012.
Here is what I am doing -
I am stopping the old release service using C# code.
NativeWinServiceMethod.ControlService(service, NativeWinServiceMethod.SERVICE_CONTROL.STOP, ref lpServiceStatus);
Then removing all the files from installed path using MSI installer exe.
And finally installing the new version again.
This upgrade works fine in windows 7 but failing in windows server.
MSI log shows 1603
I know the cause of it now but need a solution for it -
Cause -
MSI installer is uninstalling the previous version and starting to
install the new version but before the previous version could be
removed from the registry. Since service removal from registry is
taking time - new version service installation is failing.
While installing on Windows If you get 1603 error that maybe means you have failed to install visual studio redistributable package install problem. Maybe uninstall already installed version and try install new again can be fix this problem.
I am managing the installation of our product to be installed on our clients servers. The installation includes an application that is a service and I am installing that service with the command line through the installer.
The question is, when I install a new version of the application, the uninstall process I believe shuts down the service so it can remove the EXE for it. Do I have to UNINSTALL and REINSTALL the service, or do I need to just install the new application and just start the service as the new EXE for the service will be replaced?
You do not need to UNINSTALL it, but you do need to STOP it if it is running, so that the lock on the EXE is released. Once EXE is updated - you can START the service.
You should be able to update any needed files as long as the service is not running.