How can I send an OK/Cancel prompt to a user when running a script as system?

0
1
Asked By TechieGal123 On

I'm in the process of migrating users between Entra ID tenants and need to reset their systems. Since the users don't have admin rights, I created a couple of scripts: one to return to OOBE and another that performs the reset. My colleague will make it available via Company Portal for the users.

The problem is, I want to notify users before the reset happens, ideally with a dialog box asking them if they're ready to proceed. I've managed to identify the user sessions, but I'm stuck on how to send a message box that can capture their response. Any insights or sample code would be greatly appreciated!

5 Answers

Answered By ScriptyMcScriptface On

I usually go for a simple method: create a flag file. The first script can write "AwaitUser.txt", and then another script running as the user can prompt them when that file is present. Once they're confirmed, it writes "UserConfirmed.txt", allowing your main script to proceed.

Answered By ScriptMaster98 On

You might want to try using "ServiceUI" from MDT; it can help with sending interactive prompts to users. Definitely worth a shot!

Answered By DevGuru42 On

Interacting with a logged-on user from a script running under the system account can be tricky. Instead, consider running a secondary script within the user's session that communicates with your main script. This could involve methods like checking a file, using registry keys, or even setting up named pipes for the interaction.

Answered By PowerShellNinja On

Have you thought about creating a scheduled task? You can run it in the specific user context and trigger it to display your prompt. It might also help to save the output from the user's script to a file, which your system context script can then read.

Answered By CodeWizard007 On

Using PInvoke with `WTSSendMessage` should do the trick! This allows you to target a specific user session. Just remember to determine the right console session to send the message to. You can find the details on Microsoft's API documentation.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.