# Windows Service for Jenkins

**URL:** https://community.jenkins.io/t/windows-service-for-jenkins/10264
**Category:** Using Jenkins
**Tags:** question
**Created:** [October 19, 2023, 12:45pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264 "2023-10-19T12:45:34Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![egssantana](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@egssantana](https://community.jenkins.io/u/egssantana)
#### Post date: [October 19, 2023, 12:45pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/1 "2023-10-19T12:45:34Z")

</div>

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:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/3/31f37484c8b281a4f7ca0f403e4e85f3d4087b79.png)

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/6/607a199a3d284e4fd6372cb948b1d6f67ef95f8a.png)  
I’m starting the service as follows:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/4/4b6bfea67988bc0c63b32f69861105d046e536ea.png)  
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.  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/c/c78668aa0b34641a4eb7b47c4de5954f1e8ad738.png)  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/f/fb2cb3500051113eb280628f91fef8914bf44371.png)  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/1/19278fd02c679c43a85ca65f258c77739d608df2.png)

---

<div class="post-metadata">

### Author: ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)
#### Post date: [October 19, 2023, 12:58pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/2 "2023-10-19T12:58:56Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![egssantana](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@egssantana](https://community.jenkins.io/u/egssantana)
#### Post date: [October 19, 2023, 2:11pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/3 "2023-10-19T14:11:38Z")

</div>

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.  
Thanks

---

<div class="post-metadata">

### Author: ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)
#### Post date: [October 19, 2023, 2:50pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/4 "2023-10-19T14:50:36Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![egssantana](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@egssantana](https://community.jenkins.io/u/egssantana)
#### Post date: [October 19, 2023, 4:00pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/5 "2023-10-19T16:00:52Z")

</div>

My installation is in this path, what would be the file to be checked?  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/5/5ed6d5a47083288d7dd9f8c78a253e7d65a4e824.png)

---

<div class="post-metadata">

### Author: ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)
#### Post date: [October 19, 2023, 4:14pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/6 "2023-10-19T16:14:31Z")

</div>

Is there a jenkins.log file in that directory?

---

<div class="post-metadata">

### Author: ![egssantana](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@egssantana](https://community.jenkins.io/u/egssantana)
#### Post date: [October 19, 2023, 5:50pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/7 "2023-10-19T17:50:50Z")

</div>

No, it only has these files.

---

<div class="post-metadata">

### Author: ![egssantana](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@egssantana](https://community.jenkins.io/u/egssantana)
#### Post date: [October 19, 2023, 6:00pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/8 "2023-10-19T18:00:30Z")

</div>

I was doing some research and found this path:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/3/3a07276e43ff9f726b3cdb812e942e18849f13d9.png)  
And its content is as follows:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/1/1a8475ef3c2663412c00aefd45e5aa6ecc4f68c7.png)

---

<div class="post-metadata">

### Author: ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)
#### Post date: [October 19, 2023, 6:38pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/9 "2023-10-19T18:38:05Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![egssantana](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@egssantana](https://community.jenkins.io/u/egssantana)
#### Post date: [October 19, 2023, 6:50pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/10 "2023-10-19T18:50:46Z")

</div>

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:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/2/27f260abfb7f0ce841b724078bc8ed33bffa0ac9.png)

---

<div class="post-metadata">

### Author: ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)
#### Post date: [October 19, 2023, 7:16pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/11 "2023-10-19T19:16:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![egssantana](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@egssantana](https://community.jenkins.io/u/egssantana)
#### Post date: [October 19, 2023, 7:36pm UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/12 "2023-10-19T19:36:29Z")

</div>

ok, I’ll carry out the procedures.

---

<div class="post-metadata">

### Author: ![Ian\_W](https://avatars.discourse-cdn.com/v4/letter/i/cab0a1/32.png) [@Ian\_W](https://community.jenkins.io/u/Ian_W)
#### Post date: [October 21, 2023, 4:39am UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/13 "2023-10-21T04:39:17Z")

</div>

~~You can use the equivalent `sc.exe` commands/options to [uninstall an agent](https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+as+a+Windows+service#InstallingJenkinsasaWindowsservice-Uninstallation) to uninstall the controller service.~~

Forgot I had [posted this on S/O](https://stackoverflow.com/a/69126224) 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.

---

<div class="post-metadata">

### Author: ![egssantana](https://avatars.discourse-cdn.com/v4/letter/e/ed655f/32.png) [@egssantana](https://community.jenkins.io/u/egssantana)
#### Post date: [October 26, 2023, 11:35am UTC](https://community.jenkins.io/t/windows-service-for-jenkins/10264/14 "2023-10-26T11:35:53Z")

</div>

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.
