I would like to re-start a running service when my installer finish installing or uninstalling.
I have found this code:
<ServiceControl Id="SomeUniqueId" Name="NameOfTheirService"
Start="both" Stop="both"/>
But where do i attach this code to ?
to the component where my is placed ?
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="325c4bfd-6614-43e9-aedb-93661295352d" Name="Plugin" Language="1033" Version="1.0.0.0"
Manufacturer="XXX Inc." UpgradeCode="4307526e-3902-40d0-991b-bacff9b3d71b">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Property Id="XXXXXX">
<RegistrySearch Id="XXXXXX" Type="raw"
Root="HKLM" Key="SOFTWARE\XXX\XXX" Name="InstallationPath" />
</Property>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="XXXXXX">
<Component Id="ProductComponent" Guid="93118c45-f0c0-4c9e-9168-8ea905e9427c">
<File Id="pluggin" Source="C://setup.log" KeyPath="yes" Checksum="yes"/>
<ServiceControl Id="StartService" Name="servicename"
Start="both" Stop="both"/>
</Component>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="install" Level="1">
<ComponentRef Id="ProductComponent" />
<ComponentGroupRef Id="Product.Generated" />
</Feature>
</Product>
The ServiceControl element must be placed in a component that you install. From the WiX .chm:
Starts, stops, and removes services for parent Component. This element is used to control the state of a service installed by the MSI or MSM file by using the start, stop and remove attributes. For example, Start='install' Stop='both' Remove='uninstall' would mean: start the service on install, remove the service when the product is uninstalled, and stop the service both on install and uninstall.
Related
I have a wix based setup (MSI) and want to protect user settings, which are stored in the registry under HKCU, when updating my application.
For now, when I upgrade my application every registry value will be overwritten, so that the user has to set his settings again.
I also want to remove all settings, when uninstall the whole application.
Can anybody help?
My code looks like this:
<Component Id="REGISTRY_ReConnect" Guid="$(var.GUID_REGISTRY_ReConnect)">
<RegistryValue Id="_REGISTRY_ReConnect" Root="HKCU" Key="Software\exampleX\MBCA" Name="ReConnect" Value="1" Type="integer" KeyPath="yes" />
</Component>
For each of the settings in registry do the following:
Define a Property containing the default value of the setting.
Define a RegistrySearch which will extract a value of the setting from registry and put it into another Property.
Use SetProperty to (conditionally) upgrade the value of first property with the value extracted from the registry.
In your Component/RegistryValue/#Value use the value of the first property instead of explicit value.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="MyProduct" Language="1033" Version="1.1.0.0" Manufacturer="MyCompany" UpgradeCode="81a34cee-f0da-4135-9f37-53e02e4b450a">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id="1" />
<Feature Id="ProductFeature" Title="MyProduct1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolde">
<Directory Id="INSTALLFOLDER" Name="MyProduct" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<Property Id="ReConnect" Value="1" />
<Property Id="OLDRECONNECT">
<RegistrySearch Id="ReConnectSearch" Root="HKCU" Key="Software\exampleX\MBCA" Name="ReConnect" Type="raw" />
</Property>
<SetProperty Id="ReConnect" Value="[OLDRECONNECT]" After="AppSearch">OLDRECONNECT</SetProperty>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="REGISTRY_ReConnect">
<RegistryValue Id="_REGISTRY_ReConnect" Root="HKCU" Key="Software\exampleX\MBCA" Name="ReConnect" Value="[ReConnect]" Type="integer" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
I'm trying to register app to autorun when Windows is launches. I can't understand why it doesn't work?
I'm trying to do that:
<!-- Files.wxs -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:fw="http://schemas.microsoft.com/wix/FirewallExtension"> <Fragment>
<DirectoryRef Id="INSTALLLOCATION"
FileSource="..\MyApp\bin\Release\">
<Component Id ="ProductComponents"
DiskId="1"
Guid="{482A3E9A-8FCA-44C6-96C5-F7B026DF85C4}">
<File Id="MyApp.exe.config" Name="MyApp.exe.config"/>
<File Id="MyApp.exe" Name="MyApp.exe"/>
<RegistryKey
Root="HKLM"
Key="Software\Microsoft\Windows\CurrentVersion\Run">
<RegistryValue Id="MyApp.exe" Name="MyApp" Value="[INSTALLLOCATION]MyApp.exe" Type="string" />
</RegistryKey>
</Component>
</DirectoryRef>
</Fragment>
</Wix>
<!-- Product.wxs -->
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include Variables.wxi?>
<Product Id="*"
Name="$(var.ProductName)"
Language="1033"
Version="$(var.Version)"
Manufacturer="$(var.Manufacturer)"
UpgradeCode="MY_GUID">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<WixVariable Id="WixUILicenseRtf" Value="eula.rtf" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<MajorUpgrade
AllowDowngrades="no"
DowngradeErrorMessage="New version is already installed."
AllowSameVersionUpgrades="no"
Schedule="afterInstallInitialize"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="MyApp" />
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="MyApp" Level="1">
<ComponentRef Id="ProductComponents" />
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION"></Property>
<UIRef Id="WixUI_InstallDir"/>
<CustomAction Id="LaunchApp" Directory="INSTALLLOCATION" ExeCommand="[SystemFolder]cmd.exe /C start MyApp.exe" />
<InstallExecuteSequence>
<Custom Action="LaunchApp" After="InstallFinalize">NOT Installed AND NOT REMOVE</Custom>
</InstallExecuteSequence>
</Product>
</Wix>
I want to achieve auto start myApp.
The most likely issue is that it needs elevation and therefore will be blocked by UAC:
https://blogs.msdn.microsoft.com/uac/2006/08/23/elevations-are-now-blocked-in-the-users-logon-path/
and:
Program needing elevation in Startup registry key (windows 7)
If it's not that, then check that the path in the registry Run key is actually correct (in the 32-bit or 64-bit registry).
Entries in the Run key do not run "when Windows is launched". They start when the user logs on. If you really want something to run when Windows starts you need a service or a Task Scheduler entry that starts when Windows starts.
i am trying to add files in my WIX installer, however it doesn't do that at the moment. i am staring at it for hours now and i just can't see what might be the problem. the referencing seems to work alright as well as the target location. the installer runs fine up to the point when it needs to install files of course.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Wix_setup" Language="1033" Version="1.0.0.0" Manufacturer="Frank Jansen" UpgradeCode="37a42e55-dea8-47da-8f4f-fb065dd38a9e">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="Wix_setup" Level="1">
<!--create a seperate ComponentGroupRef and Fragment for each extra added program-->
<ComponentGroupRef Id="InstallationFiles" />
<ComponentGroupRef Id="DLLs" />
<ComponentGroupRef Id="IniFiles" />
<ComponentGroupRef Id="Scripts" />
<ComponentGroupRef Id="TeamViewer" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Wix_setup" />
</Directory>
</Directory>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" ></Property>
<UIRef Id="WixUI_InstallDir"/>
</Fragment>
here is also a part of the references that i made using heat:
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Directory Id="dirE31AF1F0EC087256AE3A304B079577CE" Name="Program Files">
<Directory Id="dir686DC70E77279FD983277BA8C61F0AF5" Name="ActiveX Control Pad">
<Component Id="cmp50E37DF3A2B94BC9155ED7F4A264B47B" Guid="{F3CE58FB-5E41-4CD9-B761-C1B14A4F6C5F}">
<File Id="fil0D955E35C33B26A36350F0C4D02733AF" KeyPath="yes" Source="C:\Users\fjansen\Documents\MMI installatie bestanden\MMI install files\Program Files\ActiveX Control Pad\license.txt" />
</Component>
<Component Id="cmp367C764B6CFEC27E7632FB3F5B37A3F9" Guid="{FBEC3C91-3DCD-4CF3-B58D-B7C97AEB8ACF}">
<File Id="fil084E5B485699543BB060A10BAEEC4519" KeyPath="yes" Source="C:\Users\fjansen\Documents\MMI installatie bestanden\MMI install files\Program Files\ActiveX Control Pad\ped.cnt" />
</Component>
<Component Id="cmp5EF25EC501B2689546C69D7C8B18B79F" Guid="{182C17ED-01E1-4529-A733-D3FBA7FF61EE}">
<File Id="filF5043624868A85726914B5A383640B6F" KeyPath="yes" Source="C:\Users\fjansen\Documents\MMI installatie bestanden\MMI install files\Program Files\ActiveX Control Pad\PEd.exe" />
</Component>
<Fragment>
<ComponentGroup Id="Wix_database" Directory="INSTALLFOLDER" >
<ComponentRef Id="cmp50E37DF3A2B94BC9155ED7F4A264B47B" />
<ComponentRef Id="cmp367C764B6CFEC27E7632FB3F5B37A3F9" />
<ComponentRef Id="cmp5EF25EC501B2689546C69D7C8B18B79F" />
the ComponentGroupRef's and the Fragments they are connected to are currently not yet in use and dont have an impact on the program (the Fragments are left out of this example)
can anybody see what i might have done wrong or what is missing?
thanks in advance,
i have solved the errors. it had a conflict with my reference file i still had in the project, because of that it did see it as two references to the same symbol that i declared the way heavyd suggested.
thanks for the support Heavyd.
I am new to WIX. In fact, this is my first project. So it should not be surprising that I am having issues.
I had my installer all setup and ready to roll, but this morning I needed a change made to my service, so I made the change and compiled. I build the WIX project and installed it. I started my service up and ran it, but the old code was executed. As it turns out, the old version of my service is still installed. Does this mean that the new version of the service was not packaged or that there was some kind of upgrade rule that I am missing? For some reason the PDB file got updated, but not the EXE.
Below is my wxs file. Please be kind...
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define AppName="My Service"?>
<?define MfgName="My Company"?>
<?define SourcePath="..\My Service\bin\$(var.Configuration)"?>
<Product Name="$(var.AppName)" Language="1033" Version="1.0.0.0" Manufacturer="$(var.MfgName)"
Id="*" UpgradeCode="063de86b-f12b-4af1-91ff-ce0917fffd5c" Codepage="1252">
<Package Id="*" Keywords="Installer" Description="$(var.AppName) Installer"
Manufacturer="$(var.MfgName)" Comments="My Service blah blah blah"
InstallerVersion="200" Compressed="yes" InstallScope="perMachine" SummaryCodepage="1252" />
<!--
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
-->
<Media Id="1" Cabinet="setup.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1"/>
<Property Id="DiskPrompt" Value="$(var.AppName) Installer [1]"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="CompanyFolder" Name="$(var.MfgName)">
<Directory Id="INSTALLFOLDER" Name="$(var.AppName)">
<Component Id="ServiceFile" Guid="3688d9ee-08ed-4dde-87d8-3b7a752a99bf">
<File Id="ServiceEXE" Name="My Service.exe" DiskId="1" Source="$(var.SourcePath)\My Service.exe" KeyPath="yes" Vital="yes" />
<File Id="ServicePDB" Name="My Service.pdb" DiskId="1" Source="$(var.SourcePath)\MY Service.pdb" KeyPath="no" Vital="yes"/>
<File Id="LibraryDLL" Name="library.dll" DiskId="1" Source="$(var.SourcePath)\library.dll" KeyPath="no" Vital="yes"/>
<File Id="LibraryPDB" Name="library.pdb" DiskId="1" Source="$(var.SourcePath)\library.pdb" KeyPath="no" Vital="yes"/>
<File Id="Config" Name="My Service.exe.config" DiskId="1" Source="$(var.SourcePath)\My Service.exe.config" KeyPath="no" Vital="yes"/>
<ServiceInstall Id="InstallService" Name="MyService" Type="ownProcess" ErrorControl="normal" Start="auto"
DisplayName="$(var.AppName)" Description="My Service blah blah blah">
<ServiceConfig OnInstall="yes" DelayedAutoStart="yes" />
</ServiceInstall>
<ServiceControl Id="ControlService" Name="MyService" Remove="both" Stop="both" Wait="no"/>
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<Feature Id="MainFeature" Title="$(var.AppName) Setup" Level="1">
<ComponentRef Id="ServiceFile"/>
</Feature>
</Product>
</Wix>
If the installation was successful yet the file was not updated, you should log the install to see why. For example:
msiexec /i filename.msi /lvoicewarmupx log.txt
One reason for a file to not get updated is if Windows Installer checks the version of the existing file and it is newer than the version of the file you are trying to install.
I am having trouble understanding wix documentation. I have created a simple installer that allows user to select a destination folder for app. It looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="AppName" Language="1033" Version="1.0.0.0" Manufacturer="Manufacturer" UpgradeCode="guid">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProjectFeature" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir"/>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="OeeCoach" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Insert files, registry keys, and other resources here. -->
<Component Id="EntityFramework" Guid="guid">
<File Id="EntityFramework.dll" Source="../App/bin/Release/EntityFramework.dll" KeyPath="yes" />
</Component>
<Component Id="MvvmLight.Extras" Guid="guid">
<File Id="GalaSoft.MvvmLight.Extras.WPF4.dll" Source="../App/bin/Release/GalaSoft.MvvmLight.Extras.WPF4.dll" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Now I need to check for .net 4 and its prerequisites, but I could not understand hot to do this. Documentation says that I need to use Bundle element, but compiler seems to complain when it is together with Product element in same wix file.
Any help is appreciated.
The bootstrapper is a separate project from your setup project. If you are using Visual Studio, add a new project to your solution and choose Bootstrapper project (instead of Setup project).