mohabouje / WinToast

WinToast is a lightly library written in C++ which brings a complete integration of the modern toast notifications of Windows 8 & Windows 10. Toast notifications allows your app to inform the users about relevant information and timely events that they should see and take action upon inside your app, such as a new instant message, a new friend request, breaking news, or a calendar event.
MIT License
688 stars 127 forks source link

Making WintoastLib more flexible when accessing the application.lnk #52

Closed RunkelTh closed 4 years ago

RunkelTh commented 4 years ago

At the moment the wintoast lib tries to find / create an .lnk in %APPDATA%\Microsoft\Windows\Start Menu\Programs\. We found out that this could lead to problems in enterprise environments with strongly restricted rights for user. In our special case the Programs folder (within the Start Menu) doesn't exist at all.

So I added a function to set the folder, where to create the .lnk.
--> WinToast::setCustomShellLinkPath()

e.g. WinToast::setCustomShellLinkPath(L"%APPDATA%\\<MyApplication>\\");

If the customShellLinkPath is not set, the default path is used instead.

Besides this I added some debug messages to validateShellLinkHelper and createShellLinkHelper.

RunkelTh commented 4 years ago

Seems that I've been to optimistic regarding my changes... I think I've to rethink that solution. Seems that it is indeeed necessary that the link is somewhere within the startmenu

ChristianGalla commented 4 years ago

I think there are two workarounds for restricted environments:

  1. Create the start menu shortcut via an installer that also sets the app id property.
  2. Manually create the shortcut for all users and one-time start the program and its wintoast initializer as administrator. This should update the properties of the shortcut, so on later program starts no properties must be changed.

In all cases, restricted users must have at least read access to the start menu shortcut.

RunkelTh commented 4 years ago

I think there are two workarounds for restricted environments:

1. Create the start menu shortcut via an installer that also sets the app id property.

2. Manually create the shortcut for all users and one-time start the program and its wintoast initializer as administrator. This should update the properties of the shortcut, so on later program starts no properties must be changed.

In all cases, restricted users must have at least read access to the start menu shortcut.

Hi Christin, thx for your fast reply. Adjusting our installer is what I'll check next. But I still see 2 problems, that could be solved using a customShellLinkPath:

Kind regard, Thomas

ChristianGalla commented 4 years ago

I think WinToast should check all lnk files in all directories inside the start menu folder of the current user and the all user's folder because IIRC both directories are merged into the displayed start menu of the current user.

Of course a custom path would be a nice extension, but is a normal user in a restricted environment permitted to write into the all users profile? I think they should only be able to write into their appdata?