Bug 409723 - [Feature] add appID&CLSID to existing Link
Summary: [Feature] add appID&CLSID to existing Link
Status: RESOLVED FIXED
Alias: None
Product: Snoretoast
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR wishlist
Target Milestone: ---
Assignee: Hannah von Reth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-11 17:02 UTC by Thomas
Modified: 2019-07-24 09:10 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Non working PoC (3.62 KB, patch)
2019-07-11 17:02 UTC, Thomas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas 2019-07-11 17:02:36 UTC
Created attachment 121474 [details]
Non working PoC

For some situations, it would be great to not create a new link, but add the appID and the CLSID to an existing Link while preserving the rest of the link. For example if the Symlink itself needs additional Attributes of if the appID changed, ...


I already tried myself to get it working, will continue trying, but this is my first Windows-Project ...
Comment 1 Hannah von Reth 2019-07-11 17:51:34 UTC
Hm any reason you can't remove and recreate the url?
Comment 2 Thomas 2019-07-12 07:25:11 UTC
Additional Link-Properties (Icon, Parameters, ...) would get lost.
Comment 3 Hannah von Reth 2019-07-12 07:54:26 UTC
The only scenario where a link with an app id is create I could imagine is during install.
Every installer should know about Icons and parameters?
Comment 4 Thomas 2019-07-12 08:49:58 UTC
Yes, but not every installer can handle PKEY_AppUserModel_ToastActivatorCLSID. I would have created the link first and if Windows-Version >= 8, I would have let Snoretoast add the appID and the CLSID to the existing link.

Now, we will probably (but not surely) switch to an installer that let us set arbitrary attributes (including appID and PKEY_AppUserModel_ToastActivatorCLSID) to links, so this isn't urgent anymore. Still, this feature will probably be helpful to other projects.
Comment 5 Hannah von Reth 2019-07-13 11:38:31 UTC
The recommended solution is to use snoretoast.exe in a post install step during installation to create the shortcut.
Comment 6 Thomas 2019-07-17 08:38:49 UTC
But this requires to make the installer like this:
if(Windows-Version >= 8)
    install shortcut using Snoretoast;
else
    install shortcut yourself;

add own properties to already existing shortcut;

We are making the shortcut now using the wix-installer and setting the appid and clsid ourselfs. This makes us stay with one Snoretoast-Version or keep the Snoretoast CLSID up to date, but makes us independent of dependencies during install.
Comment 7 Hannah von Reth 2019-07-17 08:58:51 UTC
Yes that's the way it was solved with nsis, and you would need to add an if clause to update the shortcut in a post install step too.

I think -v should probably report the CLSID for scripting purposes, could be handy.

Could you share the wix snippet so I can add it to the readme? :)

Cheers,

Hannah
Comment 8 Thomas 2019-07-17 09:24:18 UTC
I really don't think that this is the way you want to do it since the SnoreToast-CLSID is hardcoded into the installer at the moment. We will write an entry in the Makefile that replaces the CLSID in the wixfile dynamically.

But here it goes:
<Directory Id="ProgramMenuDir" Name="Appname">
	<Component Id="ProgramMenuDir" Guid="SOME-RANDOM-GUID">
		<RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
		<RegistryValue Root="HKLM" Key="Software\[Manufacturer]\[ProductName]\installed_shortcuts" Type="string" Value="" KeyPath="yes"/> <!-- Just done to have a keypath -->
		<Shortcut Id="startmenuNotifier" Directory="ProgramMenuDir" Name="Appname" Description="Appdec" Target="[#id_of_exe_component]" WorkingDirectory="INSTALLDIR" Icon="icon.ico" Advertise="no">
			<ShortcutProperty Key="System.AppUserModel.ID" Value="com.example.appid" />
			<ShortcutProperty Key="{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 26" Value="{SNORETOAST-GUID}"></ShortcutProperty><!-- System.AppUserModel.ToastActivatorCLSID written in hex to make it work on older Windows-Versions, too -->
		</Shortcut>
		<Shortcut Id="Uninstall" Name="Uninstall Portmaster" Target="[SystemFolder]msiexec.exe" Arguments="/x [ProductCode]" Description="Uninstalls Portmaster Application Firewall" />
		<RegistryValue Root="HKCU" Key="SOFTWARE\Classes\CLSID\{SNORETOAST-GUID}\LocalServer32" Type="string" Value="C:\snoretoast.exe" /><!-- see snoretoast: linkhelper.cpp:86 -->
	</Component>
</Directory>
Comment 9 Hannah von Reth 2019-07-17 09:52:53 UTC
Thx, yes sadly the clsid needs to be hard coded as it gets compiled into the com interface...
Comment 10 Thomas 2019-07-24 09:01:18 UTC
I added a NSIS headerfile that does exactly the same as my wix snippet, don't think you will want to use that either: https://github.com/safing/nsis-shortcut-properties
Comment 11 Hannah von Reth 2019-07-24 09:08:03 UTC
I think for nsis https://github.com/KDE/snoretoast/#shortcut-creation-with-nsis is really the easiest way. A simple macro to create a shortcut, depending on the Windows version. No need to extract the clsid etc.
Comment 12 Hannah von Reth 2019-07-24 09:10:52 UTC
But I think both scenarios should get documented in snoretoast. So thx for sharing.