title: TeamCity Access denied error while executing CodedUI tests using MSTest Runner
body: <p>I am trying to execute CodedUI Tests from TeamCity using MSTest Runner. To execute CodedUI Tests, I installed Visual Studio Test Agent on TeamCity Server and configured build step with MSTest.</p>
  
  <p>Below is the error log.</p>
  
  <pre><code>Step 5/5: Execute CodedUI Test (MSTest) (1s)  
  [18:31:25]Starting: C:\BuildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe #TeamCityImplicit  
  [18:31:25]in directory: C:\BuildAgent\work\1a7958057951b685
  [18:31:27]2015-01-02 18:31:27,536 [58756] ERROR JetBrains.BuildServer.NAntLoggers.NUnitLauncher2 - Failed to start process. Access is denied. Path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE, arguments: /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.UnitTests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.Tests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.CodedUITests\bin\CI\MobileSecurityAppCodedUITests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.Tests\bin\CI\BitwiseMobile.Tests.dll /resultsfile:C:\TeamCity\temp\buildTmp\tmp1BB9.tmp.teamcity.trx, at C:\BuildAgent\work\1a7958057951b685  
  [18:31:27]System.Exception: Failed to start process. Access is denied. Path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE, arguments: /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.UnitTests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.Tests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.CodedUITests\bin\CI\MobileSecurityAppCodedUITests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.Tests\bin\CI\BitwiseMobile.Tests.dll /resultsfile:C:\TeamCity\temp\buildTmp\tmp1BB9.tmp.teamcity.trx, at C:\BuildAgent\work\1a7958057951b685 ---&gt; System.ComponentModel.Win32Exception: Access is denied
  [18:31:27]   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
  [18:31:27]   at System.Diagnostics.Process.Start()
  [18:31:27]   at JetBrains.TeamCity.Utils.ProcessRunnerBase.Run(ProcessStartInfo psi) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\ProcessRunnerBase.cs:line 61
  [18:31:27]   --- End of inner exception stack trace ---
  [18:31:27]   at JetBrains.TeamCity.Utils.ProcessRunnerBase.Run(ProcessStartInfo psi) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\ProcessRunnerBase.cs:line 65
  [18:31:27]   at JetBrains.TeamCity.Utils.Runtime.ProcessRun.Execute(IRunProcess proc) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 123
  [18:31:27]   at JetBrains.TeamCity.Utils.Runtime.ProcessRun.Run(String executable, PlatformVersion env, PlatformType platform, EnvironmentArg[] envKeys, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 58
  [18:31:27]   at JetBrains.TeamCity.Utils.Runtime.ProcessRun.RunWithCommandLine(PlatformVersion env, PlatformType platform, String assembly, EnvironmentArg[] additionalEnvironment, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 49
  [18:31:27]   at JetBrains.TeamCity.Utils.Runtime.ProcessRun.RunWithCommandLine(PlatformVersion env, PlatformType platform, String assembly, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 41
  [18:31:27]   at JetBrains.TeamCity.Utils.Runtime.RunInRuntime.ForkInRuntime(PlatformVersion version, PlatformType type, String executable, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\RunInRuntime.cs:line 50
  [18:31:27]   at JetBrains.TeamCity.NUnitCommon.PlugableRunFactory.RunProcessAsPlugable.Run() in c:\BuildAgent\work\42f5b4bce579465c\src\TestRunnerCommon\src\PlugableRunFactory.cs:line 33
  [18:31:27]   at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.ExecuteTasks(ITestRunArguments arguments, IPlugableTestRunner[] plugRuns) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 136
  [18:31:27]   at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.Run2(String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 114
  [18:31:27]   at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.Run(String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 57
  [18:31:27]Failed to start process. Access is denied. 
      Path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE, arguments: /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.UnitTests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.Tests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.CodedUITests\bin\CI\MobileSecurityAppCodedUITests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.Tests\bin\CI\BitwiseMobile.Tests.dll /resultsfile:C:\TeamCity\temp\buildTmp\tmp1BB9.tmp.teamcity.trx, at C:\BuildAgent\work\1a7958057951b685 
      at JetBrains.TeamCity.Utils.ProcessRunnerBase.Run(ProcessStartInfo psi) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\ProcessRunnerBase.cs:line 65
      at JetBrains.TeamCity.Utils.Runtime.ProcessRun.Execute(IRunProcess proc) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 123
      at JetBrains.TeamCity.Utils.Runtime.ProcessRun.Run(String executable, PlatformVersion env, PlatformType platform, EnvironmentArg[] envKeys, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 58
      at JetBrains.TeamCity.Utils.Runtime.ProcessRun.RunWithCommandLine(PlatformVersion env, PlatformType platform, String assembly, EnvironmentArg[] additionalEnvironment, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 49
      at JetBrains.TeamCity.Utils.Runtime.ProcessRun.RunWithCommandLine(PlatformVersion env, PlatformType platform, String assembly, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 41
      at JetBrains.TeamCity.Utils.Runtime.RunInRuntime.ForkInRuntime(PlatformVersion version, PlatformType type, String executable, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\RunInRuntime.cs:line 50
      at JetBrains.TeamCity.NUnitCommon.PlugableRunFactory.RunProcessAsPlugable.Run() in c:\BuildAgent\work\42f5b4bce579465c\src\TestRunnerCommon\src\PlugableRunFactory.cs:line 33
      at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.ExecuteTasks(ITestRunArguments arguments, IPlugableTestRunner[] plugRuns) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 136
      at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.Run2(String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 114
      at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.Run(String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 57
  [18:31:27]Process exited with code -1
  [18:31:27]Step Execute CodedUI Test (MSTest) failed
  </code></pre>
  
  <p>I tried giving all possible permissions to the MSTest folder, but still its not working. I could run the MSTest.exe from command prompt but not through TeamCity.</p>