Prompt user to close program #165
Replies: 5 comments 18 replies
-
|
Hello, thanks :) |
Beta Was this translation helpful? Give feedback.
-
|
..or.. It can be created purely in PS with some effort. |
Beta Was this translation helpful? Give feedback.
-
|
I am re-opening up this discussion because this is a huge disruptor for my organization's technical team. In my opinion, it's unacceptable to have a script that will blindly kill open user programs without at least attempting to ask the user to either close the program, or defer the upgrade to a future time. Reviewing the options:
I see there's concerns about level of effort, which I'm reading as "it's going to take a long time for me to figure out how to do this and I don't have the bandwidth". That's fine. This is business critical for me, so I'm going to fork, work it out, and open a pull request to upstream the feature. I also understand that people may be hesitant about giving the keys to users to control updates (who hasn't seen users defer Windows Updates for weeks on end?) so I'm going to design this to be a configurable opt-in configuration that you need to explicitly account for. If you like it, great - use it. If you find it problematic with users - just don't enable it (selectively or in whole). For context, this is what I'm going to look to do once I find a sensible place to hook this in:
Step 1 is going to be painful part since every program under the sun uses a different "main program" (or even multiple sets of processes and/or services). If it's not feasible, an alternative is to just add the simple prompt logic of "Proceed with install, yes/no?" regardless of running processes. If there's concerns about this being too burdensome with prompting too many times, a further enhancement could be to either operate in a "default prompt all" or "default prompt none", with optional config to specify programs that shouldn't prompt (in the default all) or should prompt (in the default none). |
Beta Was this translation helpful? Give feedback.
-
|
I have a proof of concept working for this. Below are the details. TL;DR: You can see the changes on my branch michaeljbailey@02b6d59 Disable re-launching via ServiceUIServiceUI attaches to the same user context as a running instance of explorer. First off, I find this a bit problematic because it's unclear which instance of explorer it picks. I couldn't find any definitive documentation indicating which process it picks to select the right user session. For most use cases, that's fine. Better would be to use something like "query user" and searching for who has the "console" session active and picking a PID that user is running. But - that's not the problematic point! The problematic bit is that once ServiceUI attaches and launches that new session, it loses So my quick & dirty fix (this is a Proof of Concept after all) is to just pretend ServiceUI doesn't exist (lines 112- 113 in my patched Add RunAsUser and the script for prompting the interactive user sessionUsing https://github.com/KelvinTegelaar/RunAsUser, I inlined https://github.com/KelvinTegelaar/RunAsUser/blob/master/Public/Invoke-AsCurrentUser.ps1 and https://github.com/KelvinTegelaar/RunAsUser/blob/master/runasuser.psm1 into the script This one new script presents a new function RunAsUser has some pretty cool functions, including running an elevated process in the current logged in interactive user session or as a non-elevated process (I elected for the latter for security purposes). My use case? I just wanted to display a simple yes/no prompt to ask the user a question. This machinery allows us to present interactive dialog boxes, even with WGAU running in a non-interactive, privileged, console session. Technically, I have the same exact problem I was harping about "picking an interactive session to present a GUI". I have no idea how it selects it, and I suspect it suffers from the same issue that ServiceUI does. There's some special magic with RunAsUser where I'm using the Wire up Update-App to give users a choice before updating.Lines 4 - 19 have my added code to ask the users if they want to allow the specified application to update (and give them time to close it before they click "yes"), or skip the update for now. Final ResultsAnd that's it... I have to figure out how to manually install my updated version of WGAU from my branch. I originally developed the (3) changes on WGAU 1.21.13 (what my org is currently running) and applied the change diff against the head of my fork. You can find my changes right here: michaeljbailey@02b6d59 I'm not making a pull request with my current branch, because it's a super raw proof of concept that should have a ton of other considerations. I'm just putting this up here so I can open up the discussion with @Romanitho if they would even consider going in this direction and merging this functionality in (after some re-work on my side). If not, I'm going to continue maintaining this fork and will be deploying this as a monkey patch in my org's Intune deployment, since the lack of the feature is causing major pain for our technical teams. Follow-up considerationsIf we were to take this seriously, I'd consider some of the following before submitting a pull request it:
Again, I'm putting this out for consideration from the core maintainer here. If there's no interest at all, I'll just keep this privately maintained for my organization. |
Beta Was this translation helpful? Give feedback.
-
|
This would be cool to have as Admx template. If program is open, ask user to close it because there will be an update. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be very helpful to have a function to prompt the user to close a certain program.
Feel free to look into PowerShell App Deployment toolkit how it does that, and use e.g. ServiceUI.exe to prompt outside the system context. https://www.youtube.com/watch?v=2rKVq482nz0
Beta Was this translation helpful? Give feedback.
All reactions