I'm trying to run a batch script using Task Scheduler in Windows 10. The script launches a Javascript Selenium file, which launches a Chrome web browser, navigates to a Cisco wireless controller and logs in, then changes a security setting and logs back off. The problem I've run into is that the task runs fine when launched manually within Task Scheduler, and also runs fine automatically when 'Run only when user is logged on' is checked AND the user is logged in.
Whenever 'run whether user is logged on or not' is checked or the user account scheduling the task is logged in but the machine is locked (i.e., not looking directly at an open Windows desktop) the task begins but hangs indefinitely until manually stopped.
What seems to be happening is that the script launches Chrome successfully, but then focus isn't being placed on the Chrome window. With the browser running in the background, the keyboard input that should go to the browser doesn't, thus the rest of the script hangs. I suspect this might also be what's happening when I try to schedule the task to run as another user, or for it to run as hidden.
Things I've tried (mostly from TechNet and other Stack Overflow posts):
- Changing user to run as to SYSTEM
- Checking 'Run with highest privileges'
- Manually adding user name to 'Log on as a Batch Job' setting in Group Policy
- Manually moved all files to the Administrator profile directory
- Unchecked 'Start only if computer is on AC power'
- Instead of calling my script directly under Actions as C:\Selenium\RunScript.bat, called it as C:\Windows\System32\cmd.exe /c C:\Selenium\RunScript.bat
- Set the 'start in' options to C:\Selenium
Thanks for any help! For this to work, it has to run silently, as I never know when or how the host machine will be used at the two intervals during the day that the script needs to run. Therefore, I can't just leave it as 'Run only when user is logged on'. Ideally, I need for the script to run silently in the background with no user interaction required, but if nothing else, I do need it to run when the correct user account is logged in but the machine is locked. Thanks!!