I have developed windows service installer using Wix. Service is set for auto start after installation. The installer has custom dialog which will take user input and updates .config file. The input is optional.
When the input is not provided, config file is not updated.I can restart windows service from services.msc. If user provides input, a custom action(deferred) will update config file. This custom action runs with Impersonate="no" mode.
In this case, windows service auto starts after installation and everything works fine. But when I restart the service, it throws below error.
Below is the code to install service:
<Component Id="CMPFa85281c3_a329_4a93_a1d7_203fbccec31f" Guid="*" Directory="INSTALLLOCATION">
<Condition>
<![CDATA[Installed OR (SVCINSTALL <> 0)]]>
</Condition>
<RemoveFile Id="RmFa85281c3_a329_4a93_a1d7_203fbccec31f" Name="MyService.exe" On="both" />
<File Id="Fa85281c3_a329_4a93_a1d7_203fbccec31f" Source="$(var.BaseDir)\MyService.exe" KeyPath="yes" />
<ServiceInstall Id="InstallWindowsService" Name="MyService"
DisplayName="MyService"
Start="auto"
ErrorControl="normal"
Type="ownProcess"
Account="[USER_DOMAIN]\[SERVICEUSER]"
Password="[PASSWORD]"
Description="MyService"/>
<ServiceControl Id="sc_InstallWindowsService" Name="MyService"
Start="install" Remove="uninstall" Stop="both" Wait="no"/>
</Component>
Below is the code for custom action.
<CustomAction Id="UpdateConfigFiles"
Return="check"
Execute="deferred"
Impersonate="no"
BinaryKey="MyCustomAction.dll"
DllEntry="UpdateFilePath"
HideTarget="yes">
</CustomAction>
<InstallExecuteSequence>
<Custom Action="PassData" Before="UpdateConfigFiles">NOT Installed AND NOT PATCH AND NOT REMOVE</Custom>
<Custom Action="UpdateConfigFiles" Before="InstallFinalize">NOT Installed AND NOT PATCH AND NOT REMOVE</Custom>
</InstallExecuteSequence>
Judging from this kind of thing:
https://support.microsoft.com/en-us/kb/2478117
the error can be associated with insufficient privilege to start the service. There's no reason for the custom action or the configuration step to have an effect unless of course it causes the service to start with a new account or to cause it to share two services in the same process, which is what the message says. It doesn't seem that this is related to the install because there is no mechanism to cause the effect.
The scenario to reproduce is still not clear to me, but it seems that the install can start the service (and the install runs with local system account) so it succeeds, but the error message according to the KB article means that the user attempting to start it doesn't have enough privilege, and otherwise the error says the process is trying to use two accounts, perhaps one in the config file and one that the install configures.
Related
Firstly I should clarify that I am a novice and have been struggling to understand the WIX formatting, but by cobbling together examples found on-line, I now have the files installing fine so I next need to register my DLL.
I used the example here as a starting point: How to deploy a SharpShell-based shell extension via WiX? but it seems that the SharpShell tool srm.exe may not be getting called at installation.
If I manually call srm.exe as follows, it works as hoped i.e. the DLL is registered and my shell extension works.
srm install MyExtension.dll -codebase
I can also see that the registration has been successful via the Server Manager application that comes with SharpShell.
I can also manually uninstall with the following - not that this is particularly relevant to my problem but it at least confirms that the manual methods work:
srm uninstall MyExtension.dll
Here is a fragment of my WXS file. When I run the resultant MSI, the files are installed but the DLL is not being registered; confirmed via SharpShell's Server Manager. Where am I going wrong?
</Component>
<Component Id="SRMexe" Guid="C17BB61F-6471-46F9-AA87-2D14D2456632">
<File Id='srm' Name='srm.exe' DiskId='1' Source='..\MyExtension\packages\SharpShellTools.2.2.0.0\lib\srm.exe' KeyPath='yes'>
</File>
</Component>
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
<Fragment>
<CustomAction Id="InstallShell" FileKey="srm"
ExeCommand='install "[INSTALLFOLDER]\MyExtension.dll" -codebase'
Execute="deferred" Return="check" Impersonate="no" />
<CustomAction Id="UninstallShell" FileKey="srm"
ExeCommand='uninstall "[INSTALLFOLDER]\MyExtension.dll"'
Execute="deferred" Return="check" Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="InstallShell"
After="InstallFiles">
NOT Installed
</Custom>
<Custom Action="UninstallShell"
Before="RemoveFiles">
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
</InstallExecuteSequence>
</Fragment>
It doesn't look like you have any references to the Fragment with the CustomAction definitions so they are not linked into your final output MSI.
Add a CustomActionRef from your Product element to create the reference.
I am creating wix installer for windows service.
But my windows service is not getting installed under the service account which I pass instead it always installed under Local System Account. Please help.
<Component Id="MySImporterService" Guid="{3EA5076C-C3FA-4A5F-95A5-365C6919DEB4}" KeyPath="yes">
<ServiceInstall Id="MyInstall"
Type="ownProcess"
Name="MyService"
DisplayName="MyService"
Start="auto"
Account="[SERVICE.USERNAME]"
Password="[SERVICE.PASSWORD]"
ErrorControl="normal" />
<ServiceControl Id="MyControl"
Stop="both"
Remove="uninstall"
Name="MyService"
Wait="no"/>
</Component>
It seems clear that (as Cole suggests) the values for SERVICE.USERNAME and SERVICE.PASSWORD are not correct. Those identifiers are Windows Installer properties that need to resolve to valid accounts at install time. A verbose log will show if they are getting set correctly.
Another issue may be that the install might get a repair, and that will result in re-install of the service so those properties would need to be available at that time as well as at install time.
Edit: Make sure that the property names are marked Secure=Yes in your WiX, otherwise they won't get preserved properly into the Execute sequence.
I'm trying to write an Installer for my Windows Service using WiX. My executable can register/unregister itself as a Windows Service using the command line parameters --install and --uninstall. This is what I came up with:
<CustomAction Id='InstallAsService' FileKey='CCWirelessServer.exe' ExeCommand='--install' Return='check' Impersonate='no' Execute='deferred' />
<CustomAction Id='InstallAsServiceRollback' FileKey='CCWirelessServer.exe' ExeCommand='--uninstall' Return='check' Impersonate='no' Execute='rollback' />
<CustomAction Id='UninstallAsService' FileKey='CCWirelessServer.exe' ExeCommand='--uninstall' Return='check' Impersonate='no' Execute='deferred' />
<InstallExecuteSequence>
<Custom Action='InstallAsService' After='InstallFiles' >NOT Installed</Custom>
<Custom Action='InstallAsServiceRollback' Before='InstallAsService' >NOT Installed</Custom>
<Custom Action='UninstallAsService' Before='RemoveFiles' >Installed</Custom>
</InstallExecuteSequence>
Both install and uninstall basically work. But during uninstall I get the following 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.
Despite this error message, the service gets unregistered and the files are deleted without a reboot. To me this looks like the installer is checking if CCWirelessServer.exe is opened before it executes my custom action.
So my question is: How do I need to modify my install execute sequence so that this error message does no longer appear?
If you are developing for Windows Installer > 3.1 you can take a look at the MSIRESTARTMANAGERCONTROL-property to see if it it set properly or if other values would would stop displaying the message.
I could suppress the message using the following values:
<Property Id="MSIRESTARTMANAGERCONTROL" Value="Disable" Secure="yes" />
I have a project that uses the WiX extension WixUtilExtension to create a user for our Windows services. When I patch the installation (using an .msp), the custom actions RemoveUser and CreateUser are executed.
I don't want these WiX extension created custom actions to run during a patch.
I can add a condition directly to the custom action (ConfigureUsers) in the InstallExecuteSequence table of the MSI to prevent this, but I have not found a way to handle this in WiX.
Using WiX, how can I prevent RemoveUser and CreateUser from being executed during a patch?
<util:Group Id="LocalAdministrators" Name="Administrators"/>
<DirectoryRef Id="INSTALLLOCATION" DiskId="1">
<Component Id="CreateServiceAccountUser" Guid="{614550A7-C766-4B5D-9BF9-233D07EB3B69}">
<util:User Id="ServiceAccountUser"
CanNotChangePassword="yes"
CreateUser="yes"
Disabled="no"
FailIfExists="no"
LogonAsService="yes"
Name="TestUser"
Password="testuserpw"
PasswordExpired="no"
PasswordNeverExpires="yes"
RemoveOnUninstall="yes"
UpdateIfExists="yes">
<util:GroupRef Id="LocalAdministrators"/>
</util:User>
<RegistryKey Root="HKMU" Key="Software\AMT\WebBrix">
<RegistryValue Name="CreateServiceAccountUser"
Value="Common"
Type="string"
KeyPath="yes" />
</RegistryKey>
</Component>
</DirectoryRef>
You can do that in WiX:
<InstallExecuteSequence>
<Custom Action='ConfigureUsers'
After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
Here are some more conditions
Action run only during Install
Condition: NOT Installed AND NOT PATCH
Action only runs during removal of MSI
Condition: REMOVE
Action runs during Install and repair
Condition: NOT REMOVE
Action runs during Install and remove
Condition: There must be no condition
Action calls EXE installed by MSI
Condition:NOT Installed AND NOT PATCH
Run on initial installation only:
NOT Installed
Run on initial install or when repair is selected.
NOT Installed OR MaintenanceMode="Modify"
Run when being uninstalled from command line or add / remove menu.
REMOVE~="All" OR MaintenanceMode="Remove"
Although the first installation works fine, when I try to update the application to a newer version, the installer presents the following message:
Service X could not be installed. Verify that you
have sufficient privileges to install system services.
When cancelling the update installation, the software is removed and if I install again, the process finishes successfully.
I'ts important to say that both install and update are requiring elevation of privilege.
Any ideas?
Elevation of Privilege
<Package InstallerVersion="300"
Compressed="yes"
InstallScope="perMachine"
InstallPrivileges="elevated"
AdminImage="yes" />
Service configuration:
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Name="X"
DisplayName="X"
Description="X"
Start="auto"
ErrorControl="normal" />
<ServiceControl Id="StartService"
Start="install"
Stop="both"
Remove="uninstall"
Name="X" Wait="yes" />
I can be many thing. I suggest to try couple of things.
-set account
<ServiceInstall Account="NT AUTHORITY\LocalService" />
-Install the MSI package. When the error dialog comes up do not dismiss the dialog. Start services.msc or use sc.exe from the command-line to attempt to start your service. If necessary debug into your service executable directly to see why it cannot be started.
Summery from Failed to install and start Windows services in WiX installer
-Ensure that it does not depend on files being placed in the GAC.
-Use event viewer to check the error.
-What is the name of the service? there is limitation on naming the service.
-if the service is already exist it can give you that insufficient privileges error, check that the service is uninstalled before installing again. Should be part of the upgrade procedure.
Hope it will get you started.