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."
Related
I'm learning about shortcuts in Wix and have managed to create shortcuts on the desktop.
If I delete the shortcut and then run the installer again I would like the shortcut to be created again.
How can this behavior be achieved with Wix?
I have created shortcuts both with
<File Id="TestX.exe" Name="TestX.exe" Source="$(var.TestX_TargetDir)TestX.exe">
<Shortcut Id="desktopIcon" Directory="DesktopFolder" Name="TestX" WorkingDirectory='INSTALLFOLDER' Icon="IconTestX.exe" IconIndex="0" Advertise="yes" />
</File>
and
<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut"
Guid="1E0D1741-57F0-4E22-89FC-4A189E2BB7E0">
<Shortcut Id="desktopSC"
Name="MyProduct"
Description="MyProduct description"
Target="[INSTALLFOLDER]TestX.exe"
Icon="IconTestX.exe">
</Shortcut>
<RemoveFolder Id="RemoveDesktopFolder"
Directory="DesktopFolder"
On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\[Manufacturer]\[ProductName]"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
I solved this problem by using WixUI_InstallDir in the WixUI library, which added a GUI which includes the option to start a repair.
Links about the WixUI dialog library:
http://wixtoolset.org/documentation/manual/v3/wixui/wixui_dialog_library.html
http://wixtoolset.org/documentation/manual/v3/wixui/dialog_reference/wixui_installdir.html
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.
I have a msi that has its InstallScope set to "perMachine" and it creates a shortcut which is available to all the users:
<Directory Id="ProgramMenuFolder">
<Directory Id="CompanyShortcutsDir" Name="My Company" />
</Directory>
<Component Id="CMP_MainExeShortcut"
Directory="CompanyShortcutsDir"
Guid="{B857CD9E-XXXX-YYYY-F2090C50C985}">
<Shortcut Id="MyExeStartShortcut"
Name="My Product"
Description="$(var.WIX_PRODNAME)"
Target="[APPLICATIONFOLDER]MyApp.exe"
WorkingDirectory="APPLICATIONFOLDER"
Icon="my.ico" />
<RemoveFolder Id="RemoveCompanyShortcutsDir"
On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\MyCompany"
Name="MainExeShortcut"
Type="integer"
Value="1"
KeyPath="yes" />
</Component>
and the shortcut does indeed appear for all the users - so far so good !!
But I also have this fragment of code:
<Component Id="CMP_MainExeShortcutCompat"
Directory="CompanyShortcutsDir"
Guid="{C748B7C6-XXXX-YYYY-7CB1823774DC}">
<RegistryValue Root="HKMU"
Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
Name="[APPLICATIONFOLDER]MyApp.exe"
Type="string"
Value="~ WIN7RTM"
KeyPath="yes"/>
</Component>
who's purpose is to set the "Compatibility Mode" on the shortcut to be "Windows 7" - but this only happens for the user that installed our product, it doesn't get set on the shortcut for the other users who are likely to login to the PC.
Does anyone know how I can set this flag on the shortcut for all the users ?
Many Thanks,
Chris.
I'm new on wix. In need to create a shortcut to a local website.
It works fine and creates the shorcuts, but it doesn't show any icon on start menu and desktop... The website has favicon file and when I open the site I can see it perfectly - I just don't see it in the shortcut. I tried to google it but I didn't find a good answer for util:InternetShortcut..
My code is:
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcutBBBApp" Guid="---">
<util:InternetShortcut Id="ApplicationStartMenuShortcutBBBApp"
Name="BBB"
Target="http://localhost/BBB"/>
<util:InternetShortcut Id="ApplicationDesktopShortcutBBBApp"
Name="BBB"
Directory="DesktopFolder"
Target="http://localhost/BBB"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\BBB" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
There is an easier solution for that problem. Instead of using InternetShortcut, you can just use the normal Shortcut and use a trick to set the target being a url.
<SetProperty Id="URL" Value="http://yourpage.com" Sequence="execute" Before="CreateShortcuts" />
<Shortcut Directory="DesktopFolder" Id="WebShortcut" Name="Your Page" Description="Your Page Description" Target="[URL]" Icon="IconDesktop">
<Icon Id="IconDesktop" SourceFile="images\icon.ico" />
</Shortcut>
"SetProperty" can be placed somewhere in your Product tag.
"Shortcut" should be placed instead of "InternetShortcut".
It is important to have the property [URL] as a Target. As a Property it can be an url. Diretctly written it doese not work.
There might be warnings in heat/candle/light, they can be ignored.
InternetShortcut doesn't support specifying an icon like a normal Shortcut. There's an open feature request for that. Technically, IUniformResourceLocator shortcuts in Windows don't support icons, though IShellLink shortcuts do.
A little late answering this, but just needed to do the same thing. The approach I took was to use the iniFile element to write out a url file.
Two points of interest with this approach:
Since the shortcut is on the desktop and the icon file is located elsewhere on the file system, I needed to create separate components to deploy the icon file.
If the MSI is ran as a normal user with UAC turned on, the icon is not set for the shortcut. Once I disabled UAC prior to installing, the icon was set correctly.
<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="ProductInternetShortcut" Guid="{YOUR_GUID_HERE}" >
<IniFile Id="url_name"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="URL"
Value="https://my.url.com/" />
<IniFile Id="url_target"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="Target"
Value="https://my.url.com/" />
<IniFile Id="url_idlist"
Action="createLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="IDList"
Value=" " />
<IniFile Id="url_HotKey"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="HotKey"
Value="0" />
<IniFile Id="url_icon"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="IconFile"
Value="PATH_TO_ICON_FILE_ON_WORKSTATION" />
<IniFile Id="url_iconIndex"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="IconIndex"
Value="0" />
<RegistryValue Root="HKCU" Key="Software\COMPANY\PRODUCT" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="ProductFolder">
<Component Id="ShortcutIcons" Guid="{YOUR_GUID_HERE}">
<File Id="filProductIcons" KeyPath="yes" Source="PATH_TO_ICON_FILE_ON_DEVELOPER_MACHINE" />
</Component>
</DirectoryRef>
</Fragment>
In Wix you can create an InternetShortcut with an icon via the InternetShortcut Element (Util Extension).
Below is an example from an app I'm working on of adding a link to a website with an icon via the <InternetShorcut> element and placing that link on both the Desktop and the Start Menu.
Note, you may have to put the "util" prefix in front of the element name like so although I didn't have to do that: <util:InternetShortcut>.
<Directory Id="ProgramMenuFolder" Name="ProgramMenuFolder">
<Directory Id="ProgramMenuFolder.MyApplicationName" Name="MyApplicationName">
<Component Id="Component.Uninstall" Guid="215c7bec-7967-43e6-8f01-72c27fbb2a98">
<CreateFolder/>
<RemoveFolder Id="ProgramMenuFolder.MyApplicationName" On="uninstall"/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
<RegistryValue Value="0" Type="string" KeyPath="yes"/>
</RegistryKey>
</Component>
<Component Id="InternetShortcut" Guid="215c7bec-7967-43e6-8f01-72c22e505f09">
<InternetShortcut
IconFile="[INSTALLDIR]\icon.ico"
IconIndex="0"
Name="Admin Page"
Id="InternetShortcut"
Target="http://localhost:4444"
Type="link"
xmlns="http://schemas.microsoft.com/wix/UtilExtension"/>
<CreateFolder/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
<RegistryValue Value="0" Type="string" KeyPath="yes"/>
</RegistryKey>
</Component>
</Directory>
</Directory>
<Directory Id="DesktopFolder" Name="DesktopFolder">
<Component Id="InternetShortcut.1" Guid="B27DF351-6EDA-4BEF-A3AC-F12313260203">
<InternetShortcut
IconFile="[INSTALLDIR]\icon.ico"
IconIndex="0"
Name="Admin Page"
Id="InternetShortcut.1"
Target="http://localhost:4444"
Type="link"
xmlns="http://schemas.microsoft.com/wix/UtilExtension"/>
<CreateFolder/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
<RegistryValue Value="0" Type="string" KeyPath="yes"/>
</RegistryKey>
</Component>
</Directory>
<Feature Id="Complete" Title="Complete" Absent="allow" Level="1">
<ComponentRef Id="InternetShortcut"/>
<ComponentRef Id="InternetShortcut.1"/>
</Feature>
Also, see How To: Create a Shortcut to a Webpage
Installer creates 2 shortcuts on Desktop: file (FS) and internet shortcuts(IS). On uninstall FS is removed ok, but IS still exists.
Then I commented FS and tested.
Now it is created and removed successfully.
What is wrong?
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id="DesktopFolder" Name="Desktop"/>
<Directory Id="ProgramMenuFolder" Name="PMenu">
<Directory Id="ProgramMenuDir" Name="Advertised Shortcut" />
</Directory>
</Directory>
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationShortcutConf" Guid="{9FF60FF5-F1A2-413F-98FB-CF7B3101F10F}">
<Shortcut Id="CompanyUtilConfigurator1"
Directory="DesktopFolder"
Advertise="no"
Name="Company Util Configurator"
WorkingDirectory="INSTALLDIR"
Icon="CompanyUtilConfiguratorIcon.exe">
</Shortcut>
<RegistryValue Root="HKCU" Key="Software\Company LLC\Company\Util" Name="installed_conf" Type="integer" Value="1" KeyPath="yes"/>
<RemoveFolder Id="DeleteShortcutFolder1"
Directory="DesktopFolder"
On="uninstall" />
</Component>
<Component Id="ApplicationShortcut" Guid="{77C005A8-63DC-43F1-9081-84157EDED0B3}">
<Condition><![CDATA[WS_SHORTCUT_NAME<>""]]></Condition>
<util:InternetShortcut
Id="Home"
Directory="DesktopFolder"
Name="Company Util" Type="url"
Target="[WS_SHORTCUT_NAME]"/>
<RemoveFolder Id="DesktopFolder2" Directory="DesktopFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Company LLC\Company\Util" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
I tried this code for your problem and it works
<RegistryKey Root="HKCU" Key="!(wix.Manufacturer)\!(wix.Product)" Action="createAndRemoveOnUninstall">
<RegistryValue Name="FirstShortCut" Type="integer" Value="1" KeyPath="yes" />
</RegistryKey>
<Shortcut Id="FirstShortCut" Directory="DeskTopFolder" WorkingDirectory="INSTALLDIR" Advertise="no" Name="ShortCutA" Icon="chk_on.ico"/>
<Component Id="ShortCutB" Guid="{435CE3D7-047F-4bdb-9CDB-6A2AED1A1303}">
<RegistryKey Root="HKCU" Key="!(wix.Manufacturer)\!(wix.Product)" Action="createAndRemoveOnUninstall">
<RegistryValue Name="SecondShortCut" Type="integer" Value="1" KeyPath="yes" />
</RegistryKey>
<util:InternetShortcut Id="SecondShortCut" Name="Second" Target="http://www.stackoverflow.com"/>
</Component>
</DirectoryRef>
Give it a try...
Also it always helps to log the Install
Use this in the command line:
msiexec /i [msiname] /l*v [filename]