Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerShell window briefly flashes on screen when toast notification is displayed #2

Closed
desseim opened this issue May 10, 2022 · 1 comment
Labels
wontfix This will not be worked on

Comments

@desseim
Copy link
Owner

desseim commented May 10, 2022

Right when a toast notification appears on the user desktop, a PowerShell window briefly flashes (appears and immediately disappears).

This can be reproduced by simply displaying a toast notification:

PS > Import-Module .\Modules\ToastNotification
PS > Show-NotificationToLoggedInUser -Title "Notification title" -Message "This is a random message"

This behavior is not intended nor desired.

@desseim
Copy link
Owner Author

desseim commented May 10, 2022

Toast notifications are displayed by a small piece of PowerShell script, which is run from a scheduled task.
When a notification is to be shown, a scheduled task which runs powershell.exe (to, in turn, run a script which calls Show-NotificationToast with the appropriate parameters) is instantiated, registered and immediately started (then immediately deleted).

The scheduled task is set to run with the logged in user as principal, which gives it the necessary permissions to display a toast notification to said user. The rdiffbackup-wrapper "original" script may be run by a different user, especially if run from a background scheduled task / job, which wouldn't have such permission: this is why a dedicated scheduled task is necessary.

The scheduled task runs PowerShell with -WindowStyle Hidden option, so that the PowerShell window doesn't appear as the notification script runs. However, it does briefly appear, then gets immediately hidden; this is due to a Windows limitation which unconditionally allocates a console to CUI applications (contrary to GUI ones).

This is a common problem (see for example this question on StackOverflow). Commonly suggested workarounds involve either hacky wrapping applications or tools, or running the task with Run whether user is logged on or not option which is quite obscure how to set programmatically and would run the task with a (different) privileged account, defeating the purpose of our scheduled task.

A proper Windows / PowerShell solution is being discussed on GitHub, and is likely to materialize at one point. Given all the above and the low impact of the flashing windows to the end user (especially since the toast notifications here are only used to notify of unexpected errors), it is preferable to wait for "upstream" (i.e. PowerShell / Windows) to fix it.

@desseim desseim closed this as completed May 10, 2022
@desseim desseim added the wontfix This will not be worked on label May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant