wix srvany.exe as a service not running - vb.net

I have a Kofax component exe which I want to run as a service. Earlier srvany.exe is used to register the exe as a service manually. I am creating a wix msi installer which will install it as a service. After installation when I am running exe as a administrator manually then it is running perfectly and doing proper updates otherwise without admin giving some activex error. Therefore I checked "Run this program as a administrator" in exe property. My problem is the service installed by msi is not executing the exe automatically and no update happening. But if service is up and running and then I will try to run exe manually then it is giving message that "it is already running" that means service is running exe but not updating anythiing. What change should i make in below code so that service can pick the exe and run.
<Component Id="comp_KofaxCaptureQCRoute_exe" Guid="F7C1EBE7-3D7B-4E6D-8098-81EDDFD156EF" Permanent="no" Transitive="no">
<File Id="file_KofaxCaptureQCRoute_exe" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="KofaxCaptureQCRoute.exe" Source="..\QC Route\KofaxCaptureQCRoute\bin\debug\KofaxCaptureQCRoute.exe" KeyPath="yes" />
</Component>
<Component Id="comp_file_srvany" Guid="D9CA373B-66B9-4FC5-A88D-E97FDDBBD526">
<File Id="file_srvany" Source="..\QC Route\srvany.exe" KeyPath="yes" />
<ServiceInstall
Id="QCRouteService"
Type="ownProcess"
Name="QCRouteService"
DisplayName="Kofax_QCRoute_Service"
Start="auto"
Account="[SERVICEACCOUNT]"
Password="[SERVICEPASSWORD]"
ErrorControl="normal"
Vital="yes"
/>
<ServiceControl Id="Kofax_QCRoute_Service" Stop="both" Remove="uninstall" Name="QCRouteService" Wait="yes" />
<RegistryKey Root="HKLM"
Key="SYSTEM\CurrentControlSet\Services\QCRouteService\Parameters"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="Application" Value=""[#file_KofaxCaptureQCRoute_exe]"" />
</RegistryKey>
<RegistryKey Root="HKLM"
Key="SYSTEM\CurrentControlSet\Services\QCRouteService\Enum"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="0" Value="Root\LEGACY_QCROUTESERVICE\0000" />
<RegistryValue Type="integer" Name="Count" Value="1" />
<RegistryValue Type="integer" Name="NextInstance" Value="1" />
</RegistryKey>
</Component>

I believe in your service install you're trying to run it under the account specified by the properties SERVICEACCOUNT, SERVICEPASSWORD possibly taken from an example seen elsewhere.
If you don't have these properties set then you should use a ServiceInstall close to this one
<ServiceInstall
Id="QCRouteService"
Type="ownProcess"
Name="QCRouteService"
DisplayName="Kofax_QCRoute_Service"
Start="auto"
Account="LocalSystem"
ErrorControl="normal"
Vital="yes"/>
Also note your ServiceControl has omitted the Start inner text
<ServiceControl Id="Kofax_QCRoute_Service" Start="install" Stop="both" Remove="uninstall" Name="QCRouteService" Wait="yes" />

Related

WiX: How to restart Windows Explorer to install / uninstall a shell extension

I am trying to write a WiX installer that includes a managed icon shell extension (using SharpShell). I've finally figured out how to register it via Wix (I couldn't get the SharpShell registration manager to work whenn called via WiX).
During installation, the following dialog appears:
If I select "Ignore", the icon shell extension is successfully installed and Window Explorer picks up the change immediately. I'm not sure which files that its detecting as "In Use".
During uninstall, the following dialog appears:
If you select the "Automatically close and attempt to restart" option, it closes Windows Explorer, but it does not restart at the end of the installation. I have to manually restart it via task manager.
WiX Fragment Definition
The WiX fragment that defines the shell extension installation is shown below:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
<!-- This fragment was originally generated using heat with the following command line:
"$(WIX)bin\heat.exe" dir "$(SolutionDir)Icon ShellExtension\bin\$(ConfigurationName)" -dr IconShellExtensionDIR -cg IconShellExtension -var var.IconShellExtension.TargetDir -fips -g1 -gg -sfrag -srd -suid -template fragment -t "$(ProjectDir)AssemblyFileFilter.xslt" -out "$(ProjectDir)Fragments\IconShellExtension.wxs"
It was then subsequently manually modified, as file associations are defined in a different component the default icon entry had to be removed.
-->
<Fragment>
<DirectoryRef Id="IconShellExtensionDIR">
<Component Id="IconShellExtension.dll" Guid="D609F6F2-52FB-4153-8D6A-3E2B7F8C4647">
<Class Id="{A1C3600C-F3E5-300E-8167-541C62083DAA}" Context="InprocServer32" Description="IconShellExtension.UaProjectIconHandler" ThreadingModel="both" ForeignServer="mscoree.dll">
<ProgId Id="IconShellExtension.UaProjectIconHandler" Description="UA Project File Icon Handler" />
</Class>
<util:RestartResource ProcessName="explorer.exe"/>
<File Id="IconShellExtension.dll" KeyPath="yes" Source="$(var.IconShellExtension.TargetDir)\IconShellExtension.dll" />
<RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Value="" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32\1.0.0.0" Name="Class" Value="IconShellExtension.UaProjectIconHandler" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32\1.0.0.0" Name="Assembly" Value="IconShellExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9e9ad08f31c5e4fb" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32\1.0.0.0" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32\1.0.0.0" Name="CodeBase" Value="file:///[#IconShellExtension.dll]" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32" Name="Class" Value="IconShellExtension.UaProjectIconHandler" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32" Name="Assembly" Value="IconShellExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9e9ad08f31c5e4fb" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32" Name="CodeBase" Value="file:///[#IconShellExtension.dll]" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="UserAppProject\ShellEx\IconHandler" Value="{a1c3600c-f3e5-300e-8167-541c62083daa}" Type="string" Action="write" />
<RegistryValue Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Explorer" Name="GlobalAssocChangedCounter" Value="1" Type="integer" Action="write" />
</Component>
<Component Id="SharpShell.dll" Guid="174E147D-4744-492F-BC5C-F00DAA4925AA">
<File Id="SharpShell.dll" KeyPath="yes" Source="$(var.IconShellExtension.TargetDir)\SharpShell.dll" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="IconShellExtension">
<ComponentRef Id="IconShellExtension.dll" />
<ComponentRef Id="SharpShell.dll" />
</ComponentGroup>
</Fragment>
</Wix>
Goal
I want the installer to be able to install or uninstall without prompting the user about files in use, and it just auto close and restart Windows Explorer during the process. My understanding is that's what the restart manager allows, and the WixUtils RestartResource tag should do this for me.
Any help would be appreciated!
UPDATE
I have tried various different combinations of properties and attempted to remove/disable the FilesInUse dialog.
I tried setting the following combination of properties as suggested in this post:
<Property Id="MSIRMSHUTDOWN" Value="2"/>
<Property Id="MSIDISABLERMRESTART" Value="0"/>
<Property Id="MSIRESTARTMANAGERCONTROL" Value="0"/>
This performed the restart of explorer.exe during uninstall, once the uninstall sequence was completed (although the length of time the explorer was shutdown for was lengthy). However, I found that when I attempt to reinstall, it displayed the FilesInUse dialog again.
I found a solution that worked for me which I will post as the accepted answer.
The best solution that seemed to work and did not display any unwanted dialogs was to remove the MSIRMSHUTDOWN and MSIDISABLERMRESTART properties and set the following property:
<!-- The following setting seems to suppress any restart dialogs -->
<Property Id="MSIRESTARTMANAGERCONTROL" Value="Disable"/>
This cleanly added or removed my shell extension. The only issue is that the shell extension remained active until I rebooted (as this was an Icon Shell Extension only, then this was acceptable to me).

How to Kill window service when uninstalling?

I have an installer which installing window services. The code to start and stop window service is below:
<Component Id="cmp690F4EBE95710C864C32A36852D2EB2F" Guid="{F933F79A-F76B-45F9-A951-6AD31C77B180}">
<File Id="fil61E48774FB18BBADEDCE4566002C9F54" KeyPath="yes" Source="$(var.APMrelease)\LiveServer.exe" Name="LiveServer.exe" DiskId="1">
<firewall:FirewallException Id="LiveServer.exe" Name="LiveServer.exe" Description="LiveServer 2.0" Profile="all" IgnoreFailure="yes" Scope="any" />
</File>
<ServiceInstall Id="InstallLiveServerService" DisplayName=" LiveServer" Description="LiveServer 2.0" Name="LiveServer" Start="auto" Type="ownProcess" Vital="yes" ErrorControl="normal">
<util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="restart" ResetPeriodInDays="4" />
<!--<ServiceDependency Id="PostMaster" />-->
</ServiceInstall>
<ServiceControl Id="StopLiveServerService" Name="LiveServer" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
I am starting my service with custom action which is fine. But when uninstalling the installer, sometimes service get hang and unable to stop due to which uninstall fails. Is there any way to wait and then kill the service or any other workaround?

Cannot create registry key value with WiX installer

The below component does everything as expected, but fails to write the last registry key value. I get no errors.
<Component Id="ProgramMenuDir" Guid="68977683-3F36-45EF-9FF4-7B9461A42D06">
<RemoveFolder Id="ProgramMenuDir" On="uninstall" />
<RegistryKey Root="HKLM" Key="Software\Wow6432Node\[Manufacturer]\[ProductName]" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Name="APIUrl" Value="http://api.blah/" KeyPath="yes" />
<RegistryValue Type="string" Name="Token" Value="blah" />
</RegistryKey>
<RegistryKey Root="HKLM" Key="Software\Wow6432Node\[Manufacturer]\[ProductName]\Tokens" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes" />
<RegistryKey Root="HKLM" Key="Software\Wow6432Node\[Manufacturer]\[ProductName]\Tokens\WOvN+Lac+d3wRtY0uBUsAeHTYg4x7j2/NWpftWv/16qaOz3J6TpDQmvjUpQmoCWPSFdMpbrcpi4rJd56aBKkkvSR54RsS5xueaYfPgk1QmQ=" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes" />
<RegistryValue Root="HKLM" Action="write" Key="Software\Microsoft\Windows\CurrentVersion\Run" Name="[ProductName]" Value="blah" Type="string" />
</Component>
Why no write, yet no errors?
Are you just looking in the wrong place, if this is a 32 bit installer then you need to check the following location - HKLM\Software\Wow6432Node\Microsoft
Remember that these are the equivalent nodes depending on your install architecture:
32bit installer on 64bit machine:
HKLM\Software\Wow6432Node\Microsoft
32bit installer on 32bit machine or 64bit installer on 64bit machine:
HKLM\Software\Microsoft

Run as admin the shortcut from startup

I created shortcut in the Startup folder. Is it possible to add "Run as administrator" property for my shortcut by wix? here my code:
<Component Id="AutostartService" Guid="GUID">
<Condition>AUTOSTART="1"</Condition>
<RegistryKey Action="createAndRemoveOnUninstall" Root="HKCU"
Key="Software\$(var.Manufacturer)\$(var.ProductName)\$(var.ApplicationName)">
<RegistryValue Name="ShortcutAutostart"
Type="integer" Value="1"
KeyPath="yes">
</RegistryValue>
</RegistryKey>
<Shortcut Advertise="no" Directory="StartupFolder"
Name="Service"
Target="[INSTALLLOCATION]Service.exe"
Id="SHORTCUT_auto"
WorkingDirectory="INSTALLLOCATION" >
</Shortcut>
<RemoveFile Id="remove_autostart" Name="Service" On="uninstall"/>
</Component>
No, it's not supported, because it's "the wrong thing to do."

WIX not converting virtual directory to web application

I am using the following code to install a web application. It creates the virtual directory just fine, but doesn't convert the virtual directory in application. I am running IIS 7
I have searched a lot but couldn't find anything different in order to make an application of virtual directory. Can someone point what's wrong with the following code?
<Component Id="WebAppVDirComponent"
Guid="C7A4B0E8-2389-4A2A-B285-96960BEE1C51"
KeyPath="yes">
<iis:WebVirtualDir Id="VDir"
Alias="[WEB_APP_NAME]"
Directory="INSTALLDIR"
WebSite="TheWebSite" >
<!-- Turn the Virtual Directory into a web application. -->
<iis:WebApplication Id="WebApplication"
Name="[WEB_APP_NAME])"
WebAppPool="TheAppPool"/>
</iis:WebVirtualDir>
<CreateFolder/>
</Component>
Try this out. This is working perfectly fine for me.
<Component Id="VDProductCenter" Guid="493E3487-AA4C-4476-8CC0-4B1C763AF6F7" Permanent="no">
<File Id="Dummy" KeyPath="yes" Name="Dummy.txt" Source="Files/dummy.txt"></File>
<iis:WebVirtualDir Id="PCVDir" Alias="[VDNAME]" Directory="dir_Application_0" WebSite="PCWebSelectedWebSite">
<iis:WebApplication Id="PCWebApp" Name="[VDNAME]" />
</iis:WebVirtualDir>
<RegistryKey Root="HKLM" Action="createAndRemoveOnUninstall" Key="SOFTWARE\CompanyName\[ProductCode]\VirtualDirectory">
<RegistryValue Name="VDName" Type="string" Value="[VDNAME]"/>
</RegistryKey>
</Component>
<Component Id="PersistWebSiteValues" Guid="C3DAE2E2-FB49-48ba-ACB0-B2B5B726AE65" Permanent="no">
<File Id="Dummy1" KeyPath="yes" Name="Dummy1.txt" Source="Files/dummy.txt"></File>
<RegistryKey Root="HKLM" Action="createAndRemoveOnUninstall" Key="SOFTWARE\CompanyName\[ProductCode]\WebSiteValues">
<RegistryValue Name="WebSiteDescription" Type="string" Value="[WEB_WEBSITE_DESCRIPTION]"/>
<RegistryValue Name="WebSitePort" Type="string" Value="[WEB_WEBSITE_PORT]"/>
<RegistryValue Name="WebSiteIP" Type="string" Value="[WEB_WEBSITE_IP]"/>
<RegistryValue Name="WebSiteHeader" Type="string" Value="[WEB_WEBSITE_HEADER]"/>
</RegistryKey>
</Component>
<iis:WebSite Id="PCWebSelectedWebSite" Description="[PCWEB_WEBSITE_DESCRIPTION]">
<iis:WebAddress Id="AllUnassigned1" Port="[WEB_WEBSITE_PORT]" IP="[WEB_WEBSITE_IP]" Header="[WEB_WEBSITE_HEADER]" />
</iis:WebSite>
It is a sort of bug (i think). I found out at WIX newsgroup
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Problem-creating-web-application-sometimes-td6653518.html