I have a batch file I would like to run every time my Windows 7 VM restarts. I have created the batch file (and it functions as expected) as C:\example.bat. I have also setup a task in Task Scheduler with a trigger on startup and an action "start C:\example.bat". Right now the batch file doesn't trigger on startup as it is supposed to. If I change the trigger to login, the batch file triggers as expected on login. What is going on?
I already tested it here before, you should add a delay(45 to 60 seconds) when triggering a task on Windows startup.
When triggering by startup, the trigger loads the task before desktop is running(before all Windows dependencies been booted), what makes your script never run(specially when you must insert a password to open the desktop).
When triggering by logon, the task will be loaded after the desktop is completely loaded(when a user session is created, after system startup), that is the reason why it work under this condition.