WiX Add Registry Key to Customize Context Menu
Asked Answered
S

0

2

I want to create an .msi installer that will add a cascading context menu when I right-click my mouse on my desktop. First, I tried doing this using the following script, and this works fine:

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\MyApp]
"MUIVerb"="My Application"
"SubCommands"="app1;app2"
"Position"=-

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\app1]
@="Run App1"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\app1\command]
@="C:\\app1.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\app2]
@="Run App2"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\app2\command]
@="C:\\app2.exe"

However, when I tried doing the same in WiX toolset, this no longer works. I can view "My Application" when I right-click on the desktop, but there are no cascading menus ("Run App1" and "Run App2" are not displayed). Here's my XML code:

<DirectoryRef Id="TARGETDIR">
        <Component Id="RegistryEntries" Guid="ADF145F9-D3C0-4961-A463-812595B9BF60">
            <RegistryKey Root="HKCR"
                Key="DesktopBackground\Shell\MyApp"
                Action="createAndRemoveOnUninstall">
                <RegistryValue Type="string" Name="MUIVerb" Value="My Application" KeyPath="yes"/>
                <RegistryValue Type="string" Name="SubCommands" Value="app1;app2"/>
            </RegistryKey>
            <RegistryKey Root="HKLM"
            Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\app1"
                Action="createAndRemoveOnUninstall">
                <RegistryValue Type="string" Value="Run App1"/>
                <RegistryValue Key="command" Type="string" Value="C:\app1.exe"/>
            </RegistryKey>
            <RegistryKey Root="HKLM"
                Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\app2"
                Action="createAndRemoveOnUninstall">
                <RegistryValue Type="string" Value="Run App2"/>
                <RegistryValue Key="command" Type="string" Value="C:\app2.exe"/>
            </RegistryKey>
        </Component>
    </DirectoryRef>

Please help me solve the problem. Do you have any suggestions? Thank you!

Staminody answered 19/11, 2014 at 8:27 Comment(4)
With your WiX installer, are those keys being created in the registry at all? Can you verify in the second two keys for the HKLM hive that they are being placed properly?Aestivation
Hi Joe, sorry for the late reply. Yes, it is successfully written in the registry. However, no cascading menu appeared when I right-clicked on my Desktop :( I am using a Windows 7 64-bit machine.Staminody
You specify Root="HKCR" for the DesktopBacgkround\Shell\MyApp key. You shouldn't write to HKCR. This is an amalgamated view of entries contained in both HKCU and HKLM. Since your other entries are being written to HKLM, consider writing that entry there, too. Otherwise, use HKCU. Also, you should have one "thing" per Component. This will be especially true if you end up writing that key to HKCU.Nonscheduled
Hi @Joan-Gan, were you able to solve this? If so, it would be nice to post a answer. Have you tried the sugestons from @fourpastmidnight?Koss

© 2022 - 2024 — McMap. All rights reserved.