So basically what I'm trying to do is to have a number of additional parameters (namely SERVICENAME and SERVICEDISPLAYNAME) in the installer of my application (which runs a service) instead of hard-coding them in the installer. The installation runs fine with this change. However the problem I have is when I run a silent uninstall. It appears that the Service Control does not stop the service before removing it from the machine and I get a dialog box telling me that the service is still running and asking me if I want the service to be stopped before uninstalling it. What should I do to make it work (i.e. make the service control to stop the service automatically before removing it)?
The ServiceControl Element is just an abstraction for the underlying ServiceControl Table. Neither "do" anything. Instead, they merely express what needs to be done. The stopping of services is performed by the StopServices Action which gets it's orders from the aforementioned table.
In Windows Installer, properties are not persisted automatically after an installation is complete. If you log the installer you will likely find that your SERVICENAME property is null and the StopServices action doesn't know what to do with that.
Take a look at the following:
The WiX toolset's "Remember Property" pattern
If you implement this pattern, the data for SERVICENAME should be restored during the uninstall and the
Related
We have some custom implementation ICommunicationListener and in our tests we find out that during application update the CloseAsync method of the listener is not invoked. In VS when we close app it is invoked. This is important for us because we are suspecting that it cussing our troubles during update of the application – it sometimes fails so we have to write a script that delete service and type from cluster and then installation is not failing. Rolling back on failed installation was always on node where service with ICommunicationListener existed.
Is this a know problem? How to force closing on update?
I have create a small script file to test.
This my script.bat file.
sc create myService binpath= C:\Users\Admin\Desktop\test.bat start= auto
This is my test.bat file.
echo "Welcome to Wizard"
Problem Statement
I am unable to start the service from control panel Service section.
I get following error.
[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.
That is why I am using nssm.
NOW what happening is that when I run following command on powershell
.\nssm install myService, I dialogue box appears. I give it the path of my script file and click on install service.
After successfull installation of service. I go to control panel -> Service -> click on start against myService but it get paused and following dialog box appears
How can I fix this?
Is there anyother way to do it without doing manual steps and not using third party tool.
I am doing all this on window 10. Do I need any server to perform this task?
NOTE: I cannot use Always up or window scheduler in my case.
The NSSM behaviour is caused by the script terminating almost instantly. Try the following script:
echo Hello World
pause
This should allow the service to start, but you will not necessarily see a console window. Even if you tick 'allow service to interact with desktop', it will not be your desktop that it interacts with!
Windows implements 'session zero isolation' as a security feature, and this essentially prevents services interacting with end user desktops.
In terms of a solution, it's possible to write Windows 'service' applications fairly simply using Visual Studio. It's outside my area of expertise, but based on the Windows applications I'm familiar with, you would generally have a user-mode application running to provide desktop interaction. The user-mode application can interact with services hosted by the service application.
Probably this is resolved by now, but in case it helps anyone, what saved the day for me was checking again my input in the arguments field in nssm. I had an extra "-" which created the error. To edit my service, I went via nssm edit <servicename>
I would also add on the fix that worked for me. I added "" (quotes) in the argument path and that solved the issue for me.
everyone, I'm using Wix to make an installer to run a service, below are my problems:
I use a custom action to call sc.exe to install and start the service, then I use custom action to call sc.exe [stop/delete] to remove the service when uninstall. This works fine except that a messagebox says
"The setup must update files or services that cannot be updated while the system is running, if you choose to continue, a reboot will be required to complete the setup"
But in fact after I click "OK", no reboot happened, and the service uninstalled successfully, how can I get rid of this message box?
Another problem is that, after click "OK" in the message box, another messagebox will pop up and tells me that "Another program has exclusive access to file [fileA], please click retry", and after I click retry, the uninstall finished successfully. [fileA] has been removed, but another file [fildB] was left behind.
but I do use a component :
<Component
<RemoveFile ..
<RemoveFile ...
</Component>
to remove these files. and I have
<Custom Action="StopService" Before="RemoveFiles">..
<Custom Action="RemoveService" After="StopService>..
In my wix .
Anyone has some suggestions?
It seems like service may not have actually shut down by the time Windows is trying to delete it or handles or process are still open to it may be for this reason its prompting for that massage box requiring a reboot to delete.
Windows can't uninstall a service if there are process/handles open to it.
In present scenerio after reboot i guess it will delete remaining files.
Try providing wait in your Custom Action for stop and remove service Provide asyncWait in return tag.
It might Solve your problem.
You are using SC.exe to control service via. custom action instead of this i recommend you to use WIX ServiceControl element.
Try to move the StopService and RemoveService custom actions before the costing standard actions, this is where Windows Installer analyzes to see what resources are in use and decides it if will prompt the user with the mentioned message box or not.
I have a complex WIX installer that does various tasks / MSIs. One of the MSIs installs a service after which a Database MSI runs and updates the app.config for that service to contains the correct connection strings.
Currently the service is started after it is installed (this is before the Database MSI runs) meaning it has incorrect connection strings. How can I make the service start as the very last item in the installer so that it has the correct connection strings.
I assume this could be in the Bundle of the Bootstrapper but I cannot get that to work. Here is the current code within the Product.wxs which starts the service.
<ServiceControl Id="StartEMService" Start="install" Name="EMService"/>
Bundles only operate on packages so things like controlling services aren't supported. Your database package should have a ServiceControl element to stop (just in case) and restart the service. Schedule the action that updates the config file to be before the StartServices standard action.
During uninstall progress, the installer displays below message:
"The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup."
I think it's caused by the installed service is still running while uninstalling. So, I try to write a custom action to stop it. But, it seems not work.
If I set the action as Execute='deferred' Impersonate='no', it only allows me to put action between InstallInitialize and InstallFinalize, so I have to set it as "immediate".
<CustomAction BinaryKey='CustomActions' Id='StopService' DllEntry='StopService' Execute='immediate' />
<Custom Action="StopService" Before="InstallValidate">REMOVE="ALL"</Custom>
Also note that, I have to use custom action to install service manually instead of using Wix by some reasons. That's why I'm trying to remove it manually.
You cannot run an elevated custom action before InstallInitialize. If you were to install the service normally, MSI would take care of stopping the service for you and not show the in-use message.