Task Scheduler not executing batch (bat) file with MSTest commands

ѺȐeallү picture ѺȐeallү · May 25, 2012 · Viewed 15k times · Source

I have several batch files which set a log file path and start visual studio 2010 ordertests. When I execute a batch file from windows explorer it runs perfectly. The problem is that when I use the Windows Task Scheduler to run a batch file my orderedtest is not executed.

Sample Code:

::: 
::: This batch kicks off the searchinlineset test set node.
:::

SetLogPath.vbs "\\spm08r2dw\ATPData\Webportal Test Results\"

%comspec% /c "call "%VS100COMNTOOLS%vsvars32.bat" & mstest /testcontainer:"%SmartUITestInstallPath%AUTs\Tests\DemoSuite\SearchInlineSet\SearchInlineSet.orderedtest"" /nologo /usestderr

OS: Windows 7/2008 r2

Task Scheduler Configuration Images:

  1. General:

    General
    (source: vsoh.com)

  2. Settings:

    Settings
    (source: vsoh.com)

  3. Conditions:

    Conditions
    (source: vsoh.com)

  4. Edit Action:

    Edit Action
    (source: vsoh.com)

  5. Edit Trigger:

    Edit Trigger
    (source: vsoh.com)

Answer

ѺȐeallү picture ѺȐeallү · May 30, 2012

Workaround:

Navigate to the General Tab of the Scheduled Task and select "Run only when user is logged on". Now the scheduler will execute the .ordertest scheduled task. This of course requires the user to be logged on but atleast the .bat will execute on schedule.