Learn how to run a script automatically on startup in Windows 10 with step-by-step instructions and tips.
Run a script on start up on Windows 10 - Super User
Are you automating something or just running a script occasionally? Is the script directory local or on the network? As you've noticed, starting a new instance of powershell with runas won't change the user, and runasuser won't elevate the process. You'll need to do them both in the opposite order. If you are logged in as the local admin, start Powershell with RunAsUser, or through: Shift ...
This worked for me, but Run as Administrator only became available after adding powershell -f in front of the script path, so as to "complete" the command…
46 How can I automatically run a script when I log on to Windows? I'd like to run something like this whenever I log into my computer: echo %USERNAME% logged on at %DATE% %TIME% >> log.txt A bonus would be to be able to run the same script whenever I unlock the screen saver as well.