Access is denied when running as Administrator on Windows

Version information:
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_201 Oracle Corporation (32-bit)
INFO: Windows Server 2016 10.0 x86
INFO: User cache: C:\Users\phschmid.sonar\cache
INFO: SonarQube server 6.7.7
INFO: Default locale: “en_US”, source code encoding: “windows-1252” (analysis is platform dependent)

When running the following sequence (on Windows Server 2016 in an Administrator Powershell console, but the same behaviour is happening when running in an Administrator command shell):

  1. sonarscanner.msbuild begin /k:“project-name” /d:sonar.cs.vstest.reportsPaths=“C:/Jenkins/workspace/PR-TEST1/TestResults/”
  2. build.ps1 (calls msbuild to rebuild the solution)
  3. test.ps1 (runs vstest /EnableCodeCoverage)
  4. sonarscanner.msbuild end

then calling ‘sonarscanner.msbild end’ I eventually get the following error message:

INFO: Sensor C# [csharp] (done) | time=7ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=1ms
INFO: Sensor Analyzer for “php.ini” files [php]
INFO: Sensor Analyzer for “php.ini” files [php] (done) | time=0ms
INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=1ms
INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp]
INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp] (done) | time=0ms
INFO: Sensor C# Unit Test Results Import [csharp]
INFO: Parsing the Visual Studio Test Results file C:\Jenkins\workspace\PR-TEST1\TestResults
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 3:16.401s
INFO: Final Memory: 15M/247M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: java.io.FileNotFoundException: C:\Jenkins\workspace\PR-TEST1\TestResults (Access is denied)
ERROR: Caused by: C:\Jenkins\workspace\PR-TEST1\TestResults (Access is denied)
ERROR:
The SonarQube Scanner did not complete successfully
14:21:52.737 Post-processing failed. Exit code: 1

How can that happen is the code is run from an Administrator command shell? The Administrator user has full access to that directory.

I just realized that the sonar.cs.vstest.reportsPaths is supposed to point to the .trx file (not the directory containing that file). I’ve updated my code and I no longer get an ‘Access denied’ error. It still doesn’t seem to pick up any code coverage information but that’s a different issue now.

thanks for updating the thread, @Philipp_Schmid

please open a different topic for the code coverage problem (in case you haven’t found the solution in the existing topics on the community)