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

左心房为你撑大大i 提交于 2019-12-13 05:54:24

问题


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:


    (source: vsoh.com)

  2. Settings:


    (source: vsoh.com)

  3. Conditions:


    (source: vsoh.com)

  4. Edit Action:


    (source: vsoh.com)

  5. Edit Trigger:


    (source: vsoh.com)


回答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.




回答2:


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.




回答3:


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/



来源:https://stackoverflow.com/questions/10757473/task-scheduler-not-executing-batch-bat-file-with-mstest-commands

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!