Cannot run program "C:\Windows\ServiceProfiles\NetworkService\.sonar\cache\

We have Azure Devops. Local build agents. We have 2 servers with 3 agents on each server and the agents are running as services.

We are using v3 of the sonar task.

In the prepare task we are using Use standalone sonarscanner CLI (we have no problem with the sonarscanner for c# and Java, only for the code that uses this setting (Angular-code))

Workaround: If I clean the cache it can work.

2025-03-13T06:50:19.4261368Z [command]C:\Windows\system32\cmd.exe /D /S /C "E:\agent.25\_work\_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\3.1.1\sonar-scanner\bin\sonar-scanner.bat"
2025-03-13T06:50:20.3857749Z 07:50:20.375 INFO  Scanner configuration file: E:\agent.25\_work\_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\3.1.1\sonar-scanner\bin\..\conf\sonar-scanner.properties
2025-03-13T06:50:20.3958275Z 07:50:20.391 INFO  Project root configuration file: NONE
2025-03-13T06:50:20.4145626Z 07:50:20.406 INFO  SonarScanner CLI 6.2.1.4610
2025-03-13T06:50:20.4179124Z 07:50:20.406 INFO  Java 21.0.6 Microsoft (64-bit)
2025-03-13T06:50:20.4218266Z 07:50:20.406 INFO  Windows Server 2016 10.0 amd64
2025-03-13T06:50:20.4483329Z 07:50:20.438 INFO  User cache: C:\Windows\ServiceProfiles\NetworkService\.sonar\cache
2025-03-13T06:50:20.9236762Z 07:50:20.922 INFO  JRE provisioning: os[windows], arch[amd64]
2025-03-13T06:50:22.3903164Z 07:50:22.389 INFO  EXECUTION FAILURE
2025-03-13T06:50:22.3912247Z 07:50:22.390 INFO  Total time: 2.061s
2025-03-13T06:50:22.3972043Z ##[error]07:50:22.390 ERROR Error during SonarScanner CLI execution
java.lang.IllegalStateException: Failed to run the Java command
	at org.sonarsource.scanner.lib.internal.JavaRunner.execute(JavaRunner.java:78)
	at org.sonarsource.scanner.lib.internal.ScannerEngineLauncherFactory.jreSanityCheck(ScannerEngineLauncherFactory.java:60)
	at org.sonarsource.scanner.lib.internal.ScannerEngineLauncherFactory.createLauncher(ScannerEngineLauncherFactory.java:54)
	at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:123)
	at org.sonarsource.scanner.cli.Main.analyze(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:63)
Caused by: java.io.IOException: Cannot run program "C:\Windows\ServiceProfiles\NetworkService\.sonar\cache\4bafe2e94439c8193fc8c68247cb0dbaf4e80265b903288f63f128304f129bbe\OpenJDK17U-jre_x64_windows_hotspot_17.0.11_9.zip_extracted\jdk-17.0.11+9-jre\bin\java.exe": CreateProcess error=2, The system cannot find the file specified
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1170)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1089)
	at org.sonarsource.scanner.lib.internal.JavaRunner.execute(JavaRunner.java:58)
	... 5 common frames omitted
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
	at java.base/java.lang.ProcessImpl.create(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:506)
	at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:159)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1126)
	... 7 common frames omitted
2025-03-13T06:50:22.3974403Z 07:50:22.390 ERROR Error during SonarScanner CLI execution

Hi,

Can you check the file in the (uncleaned) cache and share what the permissions on it are?

 
Thx,
Ann

Network service has full control. The services is running as network service-account.

What I don’t understand is that in the step Run code analysis, so set i Jdk version. And in a previous step I have installed Java. Why do it uses it’s own Java? Why do it require Java and uses it’s own?

Hi,

We’ve started providing a JVM with the scanner to

  1. Ease adoption and use
  2. Make sure the required version is always available.

 
HTH,
Ann