Create installer with Installshield that installs Windows Service - windows-services

I have a windows service that installs itself by executing it in a cmd with the command line --install. This service also knows how uninstall itself by passing the --uninstall param in a cmd.
I need to create a MSI installer that installs this service and start it. I have tried by using Components in Installshield and using Custom Actions but not getting the rights results either way.
I need some help here. Thanks

Please see my answer under Wix installer to replace INSTSRV and SRVANY for user defined service installation
The WiX ServiceInstall and ServiceControl elements are abstractions for the underlying Windows Installer ServiceInstall and ServiceControl tables. InstallShield uses this same feature but instead of authored as XML it's authored in the components view under the advanced settings | services area of the component.
In general it's not a windows installer best practice to call a custom action to register the service. Instead figure out the details being done by the --install command and author them natively into these tables using InstallShield.
Installing, Controlling, and Configuring Windows Services

Related

How to bundle Electron application and windows service together?

I am very new with electron application. I need some help with election installation.
I have an Electron desktop application and a windows service.
I can start and stop my pre installed services by using sudo-prompt package.
I am creating windows installer by using electron-winstaller package.
But I want to bundle my windows service along with my electron application. My requirement is when I install my electron package then it should install my service also, when I uninstall my package then that service should be uninstalled.
Please help me out. Any clue, Any suggestions will be appreciated.
If you think this should be achieved with something else then please do suggest me.
Electron's windows installer packager strikes me a specific case tool that would likely hit limitations in scenarios like this. I would use a general case tool instead such as the Free and Open Source Windows Installer XML Toolset aka WiX. I would also use with that another FOSS application called Industrial Strength Windows Installer XML aka IsWiX.
WiX allows you to describe and build MSI databases using an XML/XSD domain specific language. It supports MSBuild for easy integration with your CI/CD pipeline. IsWiX* is a set of project templates and graphical designers that provide an opinionated project structuring (scaffolding) and greatly speeds up the learning curve and implementation. For example, this installer you describe could be done without writing a single line of XML.
For more information see: https://github.com/iswix-llc/iswix-tutorials
The desktop-application and windows-service tutorials should** show you everything you need to know to author this installer. Basically follow the desktop-application all the way through and then skip to the final portion of the windows-service tutorial where you define the windows service.
I'm the maintainer of IsWiX
** This assumes your service exe is a proper Windows service that interfaces with the windows service control manager. If it's really just a console app that runs as a service you will need to include a program such as srvany.exe. This will require one line of hand crafted XML to extended the service definition in the registry with the proper command line value to be passed to your exe. An example can be found here: Wix installer to replace INSTSRV and SRVANY for user defined service installation

MSI Installer fails during uninstall when serivce was already removed

I've an Installer with some custom actions & the designer fancy to install a windows service.
From times to times, when I made a mistake in my custom actions (or in the MSI configuration) the upgrade process may fail. Solution is to uninstall the Application and do a fresh installation.
But sometimes I'm ending in the situation, where I can't uninstall the Application because the "custom actions" for the service claims, that the service is not registered in the system. OK, maybe, no problem. I'm uninstalling the App. The problem: my app don't get uninstalled. It remains. I have to manually add the service to the registry again and restart the uninstall process.
Question: What do I have to configure/develop/program/etc. to tell the service (un)installer not to fail during uninstall when the service is already removed.
BTW: My custom actions do NOTHING during uninstallation. Only during installation/upgrade, I'm asking the user for some configuration and do some custom config stuff - only related to my app. Not related to the service.
EDIT: forgot to mention: VS 2008, default installer project, no fancy stuff, target machine is Windows XP
Yeah, that's one of the many reasons I say not to use VDPROJ and InstallUtil custom actions. You need to put a try catch block in your uninstall custom action and handle that scenario.
Hopefully you are testing on a VM and can just revert but in case this is your dev box use the Windows SC command to recreate the service so you can get the uninstall to work for now.
If you really want to do this right, you want to do something like this:
Augmenting InstallShield using Windows Installer XML - Windows Services
The same concept applies you'll just be adding the WiX merge module to your VDPROJ installer.

Launching a service from msi installer that depends on assemblies installed by the msi

I'm using WiX to write a MSI installer to start a service that depends on DLLs installed by the MSI. On Vista, the DLLs become added to the global assembly cache in the MSI's InstallFinalize phase, so I can't use the built-in service starting command in WiX. That one tries to start the service before the DLLs are in the GAC, and fails. The solution seems to be to use a custom action instead [1], and run that after InstallFinalize.
The custom action I used was starting the service with sc. Everything works fine when running the installer as an administrator, but running as a regular user doesn't work. The installer will elevate privileges for the actual install phase, but will drop them after finalizing the installation, and starting the service with sc as a non-privileged user will fail. Setting the custom action to be deferred and no-impersonate to get admin privileges won't work either after InstallFinalize [2].
As a final kludge, I tried to add <Condition>Privileged</Condition> to the WiX file to tell the user that the installer needs to be run as Administrator, but I couldn't get that to work either. The Privileged value gets set to 1 during the installation, maybe when the main install sequence is given higher privileges.
So has anyone else ran into the combination of Vista, non-Administrator user, installer needs to start a service and service needs stuff that goes into GAC during installation to run? Is there any kind of working general approach to this?
[1] http://www.mail-archive.com/wix-users#lists.sourceforge.net/msg09162.html
[2] http://www.mail-archive.com/wix-users#lists.sourceforge.net/msg15381.html
This is one of those times when the easiest solution is just to schedule a reboot.
Here are a few possibilities :
If possible, do not install prerequisite assemblies in the GAC. This will allow your service to be started normally (ie between InstallInitialize and InstallFinalize).
Create a bootstrapper (a small app that launches prerequisite MSIs in a certain order). Place the prerequisite assemblies (those that go in the GAC) into their own MSI, and get the bootstrapper to install them before it installs your service.
Create a launcher (an even smaller app that just launches your MSI). Give it a manifest that will make it run elevated. That way, the entire MSI is elevated, not just the part that's between InstallInitialize and InstallFinalize. You should be able to invoke sc succesfully.
I agree with #sascha. Rebooting is not just the easiest but cleanest in this case. All of the other proposed solutions are going to set you up for a much higher failure rate in the future. IMHO, the Windows Installer design w.r.t. the GAC is busted. The reboot is recognition of that.

What are the specific differences between .msi and setup.exe file?

I searched a lot, but all are guessed answers. Help me to find the exact answer.
An MSI is a Windows Installer database. Windows Installer (a service installed with Windows) uses this to install software on your system (i.e. copy files, set registry values, etc...).
A setup.exe may either be a bootstrapper or a non-msi installer. A non-msi installer will extract the installation resources from itself and manage their installation directly. A bootstrapper will contain an MSI instead of individual files. In this case, the setup.exe will call Windows Installer to install the MSI.
Some reasons you might want to use a setup.exe:
Windows Installer only allows one MSI to be installing at a time. This means that it is difficult to have an MSI install other MSIs (e.g. dependencies like the .NET framework or C++ runtime). Since a setup.exe is not an MSI, it can be used to install several MSIs in sequence.
You might want more precise control over how the installation is managed. An MSI has very specific rules about how it manages the installations, including installing, upgrading, and uninstalling. A setup.exe gives complete control over the software configuration process. This should only be done if you really need the extra control since it is a lot of work, and it can be tricky to get it right.
.msi files are windows installer files without the windows installer runtime, setup.exe can be any executable programm (probably one that installs stuff on your computer)
MSI is an installer file which installs your program on the executing system.
Setup.exe is an application (executable file) which has msi file(s) as its one of the resources.
Executing Setup.exe will in turn execute msi (the installer) which writes your application to the system.
Edit (as suggested in comment): Setup executable files don't necessarily have an MSI resource internally
MSI is basically an installer from Microsoft that is built into windows. It associates components with features and contains installation control information. It is not necessary that this file contains actual user required files i.e the application programs which user expects. MSI can contain another setup.exe inside it which the MSI wraps, which actually contains the user required files.
Hope this clears you doubt.

Uninstall before installing a windows service

I am reading about how you can create an .exe that will install a windows service to the server.
Say I already have the windows service installed and I want to perform an update. Is there a way for the installer to uninstall (stop the service, delete it, uninstall it) the currently running service and then install the updated version?
Don't be that drastic -- if possible, just stop the service, replace the files you need to, and then (optionally) restart the service.
If you delete the service from the SCM, you lose any post-install configuration done by the user -- custom logon credentials, the settings that dictate what to do when the service crashes, etc.
You shouldn't need to create an exe to do this, the "sc" command can uninstall, update, and install services on Windows for you. See:
Using SC.EXE to Develop Windows NT Services
How to create a Windows service by using Sc.exe
If you still really want to do this by creating your own executable you certainly can, if you can let us know what language you're working in code samples can be provided.

Resources