Script to reboot, login and execute a startup script, stay logged in

I have a workstation that needs to have a ‘service’ run that requires a user to log in and run, usually windows is locked after it runs so stays open. I created a simple script that runs ‘shutdown /g /f’ and I have the batch file in the startup folder. It seems to run if I run the script one by adding to the queue on the workstation but it does not seem to login and run the batch if I schedule to run every Saturday at 3 am. It reboots but does not start the batch so I have to manually login and run. Any idea why? Or what I can do to run? I have to do since updates run on that PC on Saturdays at 12 am and it’s usually reboots after.

Had a hard time following all that but I’ll take a stab. I’m not sure /g works in domain environments. It’s possible it doesn’t process Startup folder also for some reason. You might look into using GitHub - KelvinTegelaar/RunAsUser: a PowerShell module that allows you to impersonate the currently logged on user, while running PowerShell.exe as system. to run whatever it is without being logged in as them.

1 Like

Workgroup environment. The program has to stay running, like running a script as logged in user, not just excuting it once as a particular user, the program is not a service and has to keep running, basically a data broker looking for changes in certain folders. I’ll look into this to see if it can be used, thanks Isaac