Here are the steps oulined to execute a .bat driven Coded UI test at a specified time.
Create a .bat similar to the following:
set mstestPath="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE"
%mstestpath%\mstest /testcontainer:AutomatedUITest.dll /resultsfile:TestOutput.trx
Test your script by double-clicking the .bat and assure that the test is properly executing.
Assuming you name this .bat “TestRunner.bat”, you would then open Task Scheduler (pre-installed on Windows, type “Task” into the search bar to locate). You will see Task Scheduler (local) in the upper left of the window. Right-click, then select create Task. Give the task a name and choose appropriate security settings. Click the Triggers tab, and assign when you wish the test to auto-execute. In this screen you can set the appropriate time to run. Now click the Actions tab, click new and assign your script “TestRunner.bat” to execute and any parameters you may wish to feed to your script. Now choose settings and allow the test to run on demand. Ensure your test is executing properly by clicking the Task Scheduler Library underneath Task Scheduler (local), locate your task, right-click and choose run. If everything executes as expected, you can rest assured that your scheduled task will properly execute at the time(s) you have designated.
See: Running Automated Tests from the Command Line