0

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)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
ѺȐeallү
  • 2,887
  • 3
  • 22
  • 34
  • I took snapshots of the config for my scheduler task but I cannot post images being that this is my first post. :P – ѺȐeallү May 25 '12 at 18:19
  • This may not be addressing the issue itself and I realise that your batch file is working fine otherwise, but... did you try doubling the inner quotation marks on the last line (those around `%VS100COMNTOOLS%vsvars32.bat` and around `%SmartUITestInstallPath%AUTs\SmartPlant Foundation\SPWebPortal\Tests\DemoSuite\SearchInlineSet\SearchInlineSet.orderedtest`)? – Andriy M May 28 '12 at 05:49
  • And if my previous suggestion was not silly enough, here's another one: have you verified that the script invoked by Task Scheduler is the same one you were testing from Windows Explorer? – Andriy M May 28 '12 at 05:53
  • I tried doubling up on the quotes and the script would no longer execute. I double, triple checked the path on the actions tab of the scheduler and it looks correct to me. I have the path entered into the "Program/script:" input box as E:\BatchFiles\RunTests\ExecuteWP_SearchInlineSet.bat @AndriyM – ѺȐeallү May 29 '12 at 14:12
  • I'm out of (silly) ideas so far, sorry. By the way, you said you couldn't post the images (because you are a new user). If you think they might be helpful, you could upload them to some image hosting server and post the links. Someone with more reps (like me) would then be able to incorporate the pics into your post. – Andriy M May 29 '12 at 15:59
  • Task Scheduler Configuration Images: [General](http://vsoh.com/a1:1qkm.png/) [Settings](http://vsoh.com/a0:2dus.png/) [Conditions](http://vsoh.com/a1:3nnt.png/) [Edit Action](http://vsoh.com/a1:4xts.png/) [Edit Trigger](http://vsoh.com/a1:5zkl.png/) @AndriyM – ѺȐeallү May 30 '12 at 13:42
  • And if there is anything else you need to see I can screen capture and link it also. Thanks for your help. :) – ѺȐeallү May 30 '12 at 13:51
  • It's all right, I'm happy to help. Can't say anything about what you might need more, though. At first I thought (still do, actually) the issue might be with the batch file itself or with the program(s) invoked by it. But if you think the problem may have something to do with the settings in Task Scheduler, I can't suggest you anything, this is not really my area of expertise. – Andriy M May 30 '12 at 14:17
  • There's one thing I might have misinterpreted, though. What exactly does not seem to be executing, is it the entire batch itself or specifically `mstest`? – Andriy M May 30 '12 at 14:19

3 Answers3

1

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.

ѺȐeallү
  • 2,887
  • 3
  • 22
  • 34
1

Navigate to the General Tab of the Scheduled Task and select "run with highest privleges". Change the user account to SYSTEM and use a command that allows authentication parameters to be passed in the code such as the PowerShell cmdlet Start-BitsTransfer.

Also, fill in the correct start in path or arguments as necessary under the edit actions tab. I use a .bat file to kick it off, so I fill in the start in box.

Tequila
  • 844
  • 9
  • 19
  • Yes, this works. Thanks. A link to an example or more explicit steps would be helpful for novice users that stumble across the same issue I experienced, Google search, and find this page. – ѺȐeallү May 02 '13 at 18:16
0

Setting the permissions explicitly for the folder and the file to full control and giving the start in folder parameter as the path for the directory where the batch file fixed the issue for me.

Check out this link http://social.technet.microsoft.com/Forums/en-US/winservermanager/thread/d47d116e-10b9-44f0-9a30-7406c86c2fbe/