How to run sonarqube as a service in windows machine

Hi Team,
I’d like to run sonarqube as a service on my Windows server. Could someone please help me how to do this?

Hi @mouni ,

this is covered by our documentation here: Operating the Server | SonarQube Docs

hope that helps :slight_smile:

Hi @Tobias_Trabelsi thanks for prompt response. So instead of using sonar.bat file need to run this StartNTService.bat file?

You need to create the service using the command in the documentation (sc create SonarQube binPath ...) and for management you can use the StartNTService.bat and StopNTService.bat scripts.

Thanks @Tobias_Trabelsi :slight_smile:

Hi @Tobias_Trabelsi

I am facing below issue while trying to run sonarqube as a service on windows machine. As suggested I used below command and got the status as success.
sc create SonarQube binPath= “”%SONAR_HOME%\bin\windows-x86-64\wrapper.exe" -s “%SONAR_HOME%\conf\wrapper.conf”"
but while trying to run below script facing the issue. Please help on this.
wrapper | Starting the SonarQube service…
wrapper | Unable to start the service - The service did not respond to the start or control request in a timely fashion. (0x41d)
Press any key to continue . . .

Hi again @mouni ,

is the service running when you check it via the service util from windows (services.msc) ?

Hi @Tobias_Trabelsi ,
Yes its running.
Instead of using this(sc create SonarQube binPath= “”%SONAR_HOME%\bin\windows-x86-64\wrapper.exe" -s “%SONAR_HOME%\conf\wrapper.conf”"), If I’ll run only sonarstart.bat file, Is it necessary to run the file every day in order to perform code analysis?

I have followed the steps as per the document but facing the issue. Please help me on this.

Sorry maybe this was not clear enough. with the sc create command you create a new service based on the parameters that you provide. the wrapper in the case of SQ is able to understand the IPC from the windows service manager (services.msc).
After you have created the service and SQ is running you don’t need to call sonarstart.bat at all. if sonarqube is running you can go ahead and analyze your code using one of your provided scanners.