Can't run Scan sonar-scanner.bat

Template for a good new topic, formatted with Markdown:

  • ALM used (GitHub, Bitbucket Cloud, Azure DevOps)
  • CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI
  • Scanner command used when applicable (private details masked)
  • Languages of the repository
  • Only if the SonarCloud project is public, the URL
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
  • Steps to reproduce
  • Potential workaround

Run this command

sonar-scanner.bat -D"sonar.projectKey=XXXXXXX" -D"sonar.organization=XXXXXXXX" -D"sonar.sources=." -D"" -D"sonar.login=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Keep getting this error. What is wrong?

INFO: Scanner configuration file: C:\Users\germa\Downloads\sonar-scanner-\bin\..\conf\
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Windows 10 10.0 amd64
INFO: User cache: C:\Users\germa\.sonar\cache
INFO: SonarQube server 8.0.0
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=933ms
INFO: Server id: 74E9293D-AWHW8ct9-T_TB3XqouNu
INFO: User cache: C:\Users\germa\.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=193ms
INFO: Load/download plugins (done) | time=376ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=0ms
INFO: Project key: sageintacctsig_dcos-disaster-recovery
INFO: Base dir: C:\Windows\System32
INFO: Working dir: C:\WINDOWS\system32\.scannerwork
INFO: Load project settings for component key: 'sageintacctsig_dcos-disaster-recovery'
INFO: Load project settings for component key: 'sageintacctsig_dcos-disaster-recovery' (done) | time=225ms
INFO: Load project branches
INFO: Load project branches (done) | time=170ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=170ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=0ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=201ms
INFO: Load active rules
INFO: Load active rules (done) | time=5053ms
WARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings.
INFO: Organization key: sageintacctsig
INFO: Indexing files...
INFO: Project configuration:
INFO: Load project repositories
INFO: Load project repositories (done) | time=183ms
INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 18.817s
INFO: Final Memory: 6M/27M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Failed to index files
        at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.indexFiles(
        at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.index(
        at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.indexModulesRecursively(
        at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.index(
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(
        at org.sonar.core.platform.ComponentContainer.startComponents(
        at org.sonar.core.platform.ComponentContainer.execute(
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(
        at org.sonar.core.platform.ComponentContainer.startComponents(
        at org.sonar.core.platform.ComponentContainer.execute(
        at org.sonar.batch.bootstrapper.Batch.doExecute(
        at org.sonar.batch.bootstrapper.Batch.execute(
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(
        at org.sonarsource.scanner.cli.Main.execute(
        at org.sonarsource.scanner.cli.Main.execute(
        at org.sonarsource.scanner.cli.Main.main(
Caused by: java.nio.file.AccessDeniedException: C:\Windows\System32\LogFiles\WMI\RtBackup
        at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at java.base/sun.nio.fs.WindowsDirectoryStream.<init>(Unknown Source)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(Unknown Source)
        at java.base/java.nio.file.Files.newDirectoryStream(Unknown Source)
        at java.base/java.nio.file.FileTreeWalker.visit(Unknown Source)
        at java.base/ Source)
        at java.base/java.nio.file.Files.walkFileTree(Unknown Source)
        at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.indexDirectory(
        at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.indexFiles(
        ... 23 more
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

As the message says, the scanner is not able to access this directory.

Why does it try to access it? Let’s see!..

… and one of the parameters you pass to the scanner:

In short, it looks like you are running the scanner from C:\Windows\System32. You should run it inside the directory of your project. Try that, and let us know how that goes!