Cannot create registry key value with WiX installer - wix

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

Related

Wix: How to write to 32bit registers on 64 bit machine

I was looking for solution for some time but without success. I must admitt that I am begginer with wix. I have got one project (WPF + caliburn, using Visual Studio 2015) beeing compiled separately for x86 and x64. I use x64 machine to create both MSIs. Unfortunately during installation the setup always writes to 64bit registers which causes problems for the application.
I have created following components, trying to fix it using Win64="no" entry, unfortunately with no success. Can somone please advice correct component configuration?
<DirectoryRef Id="TARGETDIR">
<?if $(var.Platform)="x64"?>
<Component Id="Registry_DefaultStoragePath" Guid="123-456-789" Win64="yes">
<RegistryKey Root="HKLM"
Key="Software\KeyName" Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="DefaultStorageLocation" Value="[DEFAULTSTORAGE]" KeyPath="yes"/>
</RegistryKey>
</Component>
<Component Id="Registry_InstallType" Guid="123-456-789" Win64="yes">
<RegistryKey Root="HKLM"
Key="Software\KeyName" Action="createAndRemoveOnUninstall" >
<RegistryValue Type="string" Name="InstallType" Value="[INSTALLTYPE]" KeyPath="yes"/>
</RegistryKey>
</Component>
<?endif?>
<?if $(var.Platform)="x86"?>
<Component Id="Registry_DefaultStoragePath" Guid="132-456-789" Win64="no">
<RegistryKey Root="HKLM"
Key="Software\KeyName" Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="DefaultStorageLocation" Value="[DEFAULTSTORAGE]" KeyPath="yes"/>
</RegistryKey>
</Component>
<Component Id="Registry_InstallType" Guid="123-456-789" Win64="no">
<RegistryKey Root="HKLM"
Key="Software\KeyName" Action="createAndRemoveOnUninstall" >
<RegistryValue Type="string" Name="InstallType" Value="[INSTALLTYPE]" KeyPath="yes"/>
</RegistryKey>
</Component>
<?endif?>
The main problem is that <?if $(var.Platform)="x64"?> is handled by the preprocessor, so it is evaluated at compile-time, not runtime.
In order to handle x86/x64 runtime you can do this:
<component ....>
<condition>NOT VersionNT64</condition>
<!-- 32 bit component -->
<!-- Add component content here -->
</component>
<component ....>
<condition>VersionNT64</condition>
<!-- 64 bit component -->
<!-- Add component content here -->
</component>

wix srvany.exe as a service not running

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" />

Wix Toolset. Unable to Delete Registry Keys on Uninstall

I wrote an Installer with Wix. Everything works but I can't delete Registry Keys on Uninstall; the log says
Disallowing uninstallation of component: {...} since another client
exists
. The code is
<ComponentGroup Id="RegistryGroup">
<Component Id="_FB6B829B_467B_4EB8_B90C_9FF64097AD38" Guid="3FBC3951-B566-4EB9-842C-9FB70A8ECDE6" Transitive="no" Directory="TARGETDIR">
<RegistryKey Root="HKCU" Key="Software" ForceCreateOnInstall="no" ForceDeleteOnUninstall="no" />
</Component>
<Component Id="_F47C127C_2EAC_4F0C_B742_03FFBCABE8AE" Guid="A5D5FF6A-1EEA-4941-9DC5-573FDCB595A5" Transitive="no" Directory="TARGETDIR">
<RegistryKey Root="HKCU" Key="Software\[Manufacturer]" ForceCreateOnInstall="no" ForceDeleteOnUninstall="yes" />
</Component>
<Component Id="_684BCAC8_3162_4C7C_93A3_908CA1485F5C" Guid="92BF7699-68B1-44EE-BDE8-AF7E7CEB0EB0" Transitive="no" Directory="TARGETDIR">
<RegistryKey Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" ForceCreateOnInstall="no" ForceDeleteOnUninstall="yes" />
</Component>
<Component Id="_FC3941D7_6617_4313_8257_5C3DE03A9838" Guid="7DCD2392-AC9A-4690-BC99-FEACAA774B08" Transitive="no" Directory="TARGETDIR">
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Name="ProductName" Value="[ProductName]" />
</Component>
<Component Id="_B86DABB3_7467_428B_9ECF_A6F59DB594E4" Guid="7A61E342-9764-4AA4-86A9-87C7A9C1DB09" Transitive="no" Directory="TARGETDIR">
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Name="ProductCode" Value="[ProductCode]" />
</Component>
<Component Id="_201EDD75_B6C7_4873_8AF9_06230F421B4F" Guid="52AE095B-FDEE-4923-B78A-F314BC26C6B6" Transitive="no" Directory="TARGETDIR">
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Name="Company" Value="[Manufacturer]" />
</Component>
<Component Id="_B76910AF_8752_45C2_98BF_80724406E3F9" Guid="81B183E7-67CA-4EF6-848E-55F8299B0A5C" Transitive="no" Directory="TARGETDIR">
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Name="ProductVersion" Value="[ProductVersion]" />
</Component>
<Component Id="_9BF1C162_A7A6_4B43_9D7C_6BD85C6C4F27" Guid="A571BA72-2216-49F0-AC28-E72C0866E9A3" Transitive="no" Directory="TARGETDIR">
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Name="Location" Value="[TARGETDIR]" />
</Component>
<Component Id="_B140E686_B49A_4BE4_93B3_DEEB07E5218E" Guid="F8996C3A-48EA-40DD-818B-5DC095B5F46F" Transitive="no" Directory="TARGETDIR">
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Name="Author" Value="[ARPCONTACT]" />
</Component>
<Component Id="_801F11AF_23B6_4C63_AEE7_05EB877E6543" Guid="0EC7189F-95BE-411E-BE48-A469032923F4" Transitive="no" Directory="TARGETDIR">
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Name="Website" Value="[ARPHELPLINK]" />
</Component>
</ComponentGroup>
What's wrong?
You have two or more installs with components that share the same GUIDs. You probably have authored upgrades of your install incorrectly in some way so every time you tested your installation you were adding more references to the GUIDs tied to these registry keys. You may also have more than one installation on your machine of your product.
You should have a bunch of registry entries under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\S-1-5-18\Components{GUID} Note that the GUID is going to be a different format due to endianness (I think) May help
I would suggest testing your installer in a clean environment preferably on a VM with a clean snapshot you can revert to in case you author a broken installer and are unable to install/uninstall/upgrade the installer and get your machine into a bad state.

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