Windows Service for Jenkins

Jenkins setup:
Good morning guys!
I recently installed Jenkins for Windows following the installation instructions on the Jenkins website.
In the last part, the Windows service is not running the Jenkins service and is showing the error below:

I’m starting the service as follows:
Jenkins opens and I can work in it normally, but I need to run the service automatically.
Has anyone experienced this problem and could give me a tip on how to resolve it?
I have also tried installing the service inside Jenkins where it gives the message that the service has already been installed.

The code you show in the notepad is not how you start a service on Windows. The service should be controlled via the “Services” snap-in. My guess is that if you are running it using the code you show in Notepad and then try and start it via the Services snap-in, the service can’t start because the port is already controlled by the instance of Jenkins that you are starting there. You should kill the Java process that you started via the commands and only use “Services” to manage the service.

Good morning Alex!
I understood your question, I showed the .bat just to show how the service is being started today. Even if I turn off the computer and without running the bat it shows the error when trying to start the JENKINS service through Windows. I’ve already done this test.

Try looking at the log files. The log file for the service wrapper should be in C:\Program Files\Jenkins (unless you changed the install path).

My installation is in this path, what would be the file to be checked?

Is there a jenkins.log file in that directory?

No, it only has these files.

I was doing some research and found this path:

And its content is as follows:

Ah, that’s the one. I’m really confused as to what is going on on your system. Did you have a Jenkins service already running on the platform previously? Did you uninstall it before trying to install the new one? Did you use the Windows installer to install the new one?

This installation is new, Jenkins has never been installed, this is the first time.
For installation I used the " jenkins.msi " installer.
For installation I used the files below:

This is what I would do:

  1. Make sure all Java processes that are running jenkins.war are killed
  2. Uninstall Jenkins using Settings > Apps
  3. Make sure no service named jenkins is shown in the Services snap-in
  4. Install Jenkins using the installer, this should install the service and start it

There should be no need to click the “Install As Windows Service” in the Global Configuration, in fact, if you see “Install As Windows Service” that means Jenkins is not setup correctly by the installer.

ok, I’ll carry out the procedures.

You can use the equivalent sc.exe commands/options to uninstall an agent to uninstall the controller service.

Forgot I had posted this on S/O before.

backup the %JENKINS_HOME% first if you have contents!
Once the service is uninstalled, then you should be able to proceed to uninstall then reinstall the msi

Or you can play around with the sc.exe to reconfigure the service to point to your current installation.

It’s messy when you have installed something as a service and manage it as if from the command line. People get into trouble with Unix and systemd with manual edits and updates instead of using the tool and package manager.

1 Like

Thank you Williams!
I managed to solve the problem, after a few visits to the WEB and a review of my installation I discovered that the user I was using did not have permission to start the Windows service.
Thank you very much for your attention.