ShortcutProperties.wxs 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  2. <Fragment>
  3. <?include ..\Includes.wxi?>
  4. <!--
  5. Properties and related actions for specifying whether to install start menu/desktop shortcuts.
  6. -->
  7. <!-- These are the actual properties that get used in conditions to determine whether to
  8. install start menu shortcuts, they are initialized with a default value to install shortcuts.
  9. They should not be set directly from the command line or registry, instead the CREATE* properties
  10. below should be set, then they will update these properties with their values only if set. -->
  11. <Property Id="STARTMENUSHORTCUTS" Value="1" Secure="yes"></Property>
  12. <Property Id="DESKTOPSHORTCUTS" Value="1" Secure="yes"></Property>
  13. <Property Id="STARTUPSHORTCUTS" Value="1" Secure="yes"></Property>
  14. <!-- These properties get set from either the command line, bundle or registry value,
  15. if set they update the properties above with their value. -->
  16. <Property Id="CREATESTARTMENUSHORTCUTS" Secure="yes">
  17. <RegistrySearch Id="CreateStartMenuShortcutsSearch" Root="HKCR" Key="$(var.RegKeyRoot)" Name="STARTMENUSHORTCUTS" Type="raw" />
  18. </Property>
  19. <Property Id="CREATEDESKTOPSHORTCUTS" Secure="yes">
  20. <RegistrySearch Id="CreateDesktopShortcutsSearch" Root="HKCR" Key="$(var.RegKeyRoot)" Name="DESKTOPSHORTCUTS" Type="raw" />
  21. </Property>
  22. <!-- Component that persists the property values to the registry so they are available during an upgrade/modify -->
  23. <DirectoryRef Id="INSTALLFOLDER_INNER">
  24. <Component Id="Product.Registry.PersistedStartMenuShortcutProperties1" Guid="62F79BCF-3367-4ACF-950F-F8BCABACDDC0" Condition="STARTMENUSHORTCUTS = 1 OR STARTMENUSHORTCUTS = &quot;Y&quot; OR STARTMENUSHORTCUTS = &quot;y&quot;">
  25. <RegistryKey Root="HKCR" Key="$(var.RegKeyRoot)">
  26. <RegistryValue Type="string" Name="STARTMENUSHORTCUTS" Value="1" KeyPath="yes" />
  27. </RegistryKey>
  28. </Component>
  29. <Component Id="Product.Registry.PersistedStartMenuShortcutProperties0" Guid="8EA2D5A8-6E5D-4BDD-9019-2099297FF519" Condition="NOT (STARTMENUSHORTCUTS = 1 OR STARTMENUSHORTCUTS = &quot;Y&quot; OR STARTMENUSHORTCUTS = &quot;y&quot;)">
  30. <RegistryKey Root="HKCR" Key="$(var.RegKeyRoot)">
  31. <RegistryValue Type="string" Name="STARTMENUSHORTCUTS" Value="0" KeyPath="yes" />
  32. </RegistryKey>
  33. </Component>
  34. <Component Id="Product.Registry.PersistedDesktopShortcutProperties1" Guid="1BBAD054-6EC2-4362-BF1B-E8BDE988B597" Condition="DESKTOPSHORTCUTS = 1 OR DESKTOPSHORTCUTS = &quot;Y&quot; OR DESKTOPSHORTCUTS = &quot;y&quot;">
  35. <RegistryKey Root="HKCR" Key="$(var.RegKeyRoot)">
  36. <RegistryValue Type="string" Name="DESKTOPSHORTCUTS" Value="1" />
  37. </RegistryKey>
  38. </Component>
  39. <Component Id="Product.Registry.PersistedDesktopShortcutProperties0" Guid="FA992614-D2E1-4795-9696-D45A5EF1B9C8" Condition="NOT (DESKTOPSHORTCUTS = 1 OR DESKTOPSHORTCUTS = &quot;Y&quot; OR DESKTOPSHORTCUTS = &quot;y&quot;)">
  40. <RegistryKey Root="HKCR" Key="$(var.RegKeyRoot)">
  41. <RegistryValue Type="string" Name="DESKTOPSHORTCUTS" Value="0" />
  42. </RegistryKey>
  43. </Component>
  44. </DirectoryRef>
  45. <!-- If a property value has been passed via the command line (which includes when set from the bundle), the registry search will
  46. overwrite the command line value, these actions temporarily store the command line value before the registry search
  47. is performed so they can be restored after the registry search is complete -->
  48. <SetProperty Id="SavedStartMenuShortcutsCmdLineValue" Value="[CREATESTARTMENUSHORTCUTS]" Before="AppSearch" Sequence="first" Condition="CREATESTARTMENUSHORTCUTS" />
  49. <SetProperty Id="SavedDesktopShortcutsCmdLineValue" Value="[CREATEDESKTOPSHORTCUTS]" Before="AppSearch" Sequence="first" Condition="CREATEDESKTOPSHORTCUTS" />
  50. <!-- If a command line value was stored, restore it after the registry search has been performed -->
  51. <SetProperty Action="RestoreSavedStartMenuShortcutsValue" Id="CREATESTARTMENUSHORTCUTS" Value="[SavedStartMenuShortcutsCmdLineValue]" After="AppSearch" Sequence="first" Condition="SavedStartMenuShortcutsCmdLineValue" />
  52. <SetProperty Action="RestoreSavedDesktopShortcutsValue" Id="CREATEDESKTOPSHORTCUTS" Value="[SavedDesktopShortcutsCmdLineValue]" After="AppSearch" Sequence="first" Condition="SavedDesktopShortcutsCmdLineValue" />
  53. <!-- If a command line value or registry value was set, update the main properties with the value -->
  54. <SetProperty Id="STARTMENUSHORTCUTS" Value="" After="RestoreSavedStartMenuShortcutsValue" Sequence="first" Condition="CREATESTARTMENUSHORTCUTS AND NOT (CREATESTARTMENUSHORTCUTS = 1 OR CREATESTARTMENUSHORTCUTS = &quot;Y&quot; OR CREATESTARTMENUSHORTCUTS = &quot;y&quot;)" />
  55. <SetProperty Id="DESKTOPSHORTCUTS" Value="" After="RestoreSavedDesktopShortcutsValue" Sequence="first" Condition="CREATEDESKTOPSHORTCUTS AND NOT (CREATEDESKTOPSHORTCUTS = 1 OR CREATEDESKTOPSHORTCUTS = &quot;Y&quot; OR CREATEDESKTOPSHORTCUTS = &quot;y&quot;)" />
  56. </Fragment>
  57. </Wix>