I'm currently using Windows 10 and have figured out a way to run a Powershell script automatically at user login by creating a scheduled task that activates a Node.js script with admin permissions. This Node.js script downloads the appropriate Powershell script from a server, and everything works smoothly. However, I've run into a snag with Windows 11. The UAC (User Account Control) is now blocking my Powershell script from running without manual intervention, which means I can't automate the process like before.
I've considered turning off UAC completely, but that's not a viable option as it requires changing settings for all users on the machine. I'm exploring another possible solution: modifying my Node.js script to download the Powershell script locally instead of running it directly. Then I would create a separate scheduled task (with admin privileges) to execute the Powershell script after a 30-second delay upon login. The challenge is that each user's Powershell script will have a different name. Any thoughts or suggestions on how to tackle this?
5 Answers
Who thinks this might be an X;Y problem? Sometimes the best solutions come from stepping back and re-evaluating the entire approach.
It sounds like you're trying to avoid a complex setup that could easily raise security flags. Maybe you should rethink the whole process? Instead of using a combination of scheduled tasks and Node.js to fetch and run the scripts, could there be a simpler way to achieve what you need without requiring elevated permissions? It might not only save you the hassle but also help your scripts avoid getting flagged as potential malware.
What’s the overall goal here? Knowing the use case might help others provide more tailored advice.
Have you thought about eliminating the need for admin rights entirely? You might want to explore impersonating the user with the SYSTEM account, which could allow the Powershell script to run without triggering UAC issues. I can't share the exact code right now, but it’s definitely worth looking into!
If you're only using Node.js to download the Powershell script, consider just sticking with Powershell to handle this task. It's perfectly capable of making HTTP requests and downloading files, which could simplify your setup a lot.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically