Forum Discussion

ChrisA_1's avatar
ChrisA_1
Occasional Contributor
13 years ago

Windows 7 Scheduled Task fails...

I have a batch file that is scheduled to start my automation every morning at 5:30 AM. It always fails at the exact same location for the exact same reason - a checkpoint is not visible.



Interestingly enough, if I manually kick off the scheduled task (inside task scheduler) or run the batch file manually, everything works fine.



I've even tried setting the task's time for 7:30 (When I get here) - and still the same thing.



I've tried it with and without the primary monitor being on. No luck reporducing it.



Any ideas?

9 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    While the primary monitor may not be the problem, what about whether or not the user is logged on and able to interact with the GUI?  Is it possible that, after a period of time, a screen saver or something kicks in and locks out the user, requiring a login to access the desktop?  
  • ChrisA_1's avatar
    ChrisA_1
    Occasional Contributor
    Great question - sadly I thought of that the  day I set it up. So I tunred off any/all screensavers/power options that might affect this. When I come in and turn on the monitors (I turn them off manually) I'm looking at the desktop - right as I've left it.



    I shut down TC everynight just to make sure it doesn't run into the "Already running:" message, along with the shutting down the AUT as well.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    What about, in Windows 7, user roles?  Could it be possible that the user that is running the task automatically at 5:30 has certain limitations that does not allow certain functions but meanwhile, you coming in have a higher level of access?  Just another point of investigation.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Well, I know that Windows scheduled tasks can be configured to "run as" a particular user.  Didn't know if that was the problem. ;-)



    In any case, are there any screen shots or other information in the log that would give some reference as to whether or not the item was visible?  



    You could also do what I like to call "Watching the paint dry"... set up the task to run at a time when you can just sit there and watch it to see if you can see what's going on.
  • ArtemS's avatar
    ArtemS
    SmartBear Alumni (Retired)
    Hi Chris,

     

    Try running the task under the BUILTIN\INTERACTIVE user account. This is a built-in account which permits the testing tool to simulate user actions over the application.



    There can be one more reason related to user privileges under Windows 7, Windows Vista or Windows Server 2008.

    By default, the applications invoked by Task Scheduler have the privileges of a standard user, regardless of the privilege level of a user who created this task. Try to elevate the permissions of a task so that it is run with the administrator privileges (enable the Run with highest privileges task property).



    To modify the task properties:


    1. Open Control Panel.

    2. Select the System and Maintenance | Administrative Tools item.

    3. Double-click the Task Scheduler applet. The Task Scheduler snap-in will be opened in the Management Console.

    4. Click the Task Scheduler Library folder in the console tree.

    5. Locate the task in the console window.

    6. Right-click the needed task and select Properties from the context menu. The Task Properties dialog will be displayed.

  • ChrisA_1's avatar
    ChrisA_1
    Occasional Contributor
    You're going to love this - it already was set to Run with Highest Privileges...



    What now?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Let's start looking at your actual test and test code to see if this is something that needs to be solved in code.  Let's do two thing:



    1)  As I suggested above, you might want to try "watching paint dry".  Set up the task to auto trigger and sit back and watch and see what happens in case something odd is happening that you're not obvserving in your manual runs

    2)  Could you post the relevant script code or, if you're using a keyword test, a screen shot showing the keyword test with the Operation, Object, and Parameters fields clearly visible?



    That would help a lot with debugging.  My suspicion, though, is the same that I mentioned above... that somehow the relevant window is being masked or made unavailable due to some sort of security issues on the box in question that is different between having the automatically executed task versus a manually triggered one.
  • leeasdf9's avatar
    leeasdf9
    Frequent Contributor
    Hi, i have had similar issue of testcomplete daily run with with Win7 Task scheduler. The very first teststep is a doubleclick on my jnlp shortcut on desktop to invoke login mask. The execution works fine by day and by "Watching the paint dry", but it always fails for nightly run.

    The doubleclick action was performed and request is sent, but login mask just does not display.

    Then i tried to diable the screen saver and it works fine again. Somehow the screen saver was the trouble maker in my case. I just did not find logical explaination for this behaviour.



    Sys.Process("explorer").Window("Progman", "Program Manager", 1).Window("SHELLDLL_DefView", "", 1).Window("SysListView32", "FolderView", 1).DblClickItem("myjnlpshortcut")