# Jenkins Agent Auto-Start on Windows Without Keeping CMD Open

**URL:** <https://community.jenkins.io/t/jenkins-agent-auto-start-on-windows-without-keeping-cmd-open/33178>\
**Category:** Ask a question\
**Created:** [June 24, 2025, 10:52am UTC](https://community.jenkins.io/t/jenkins-agent-auto-start-on-windows-without-keeping-cmd-open/33178 "2025-06-24T10:52:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![siro2029](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@siro2029](https://community.jenkins.io/u/siro2029)\
**Post date:** [June 24, 2025, 10:52am UTC](https://community.jenkins.io/t/jenkins-agent-auto-start-on-windows-without-keeping-cmd-open/33178/1 "2025-06-24T10:52:57Z")

</div>

I hope this message finds you well.

I am currently building a Jenkins environment on a Windows server. I would like to register another Windows server as a node and run jobs on that server.

To launch the agent, I have been using the following command in the command prompt (CMD):

> java -jar agent.jar -url [http://10.10.10.10:8080/](http://10.10.10.10:8080/) -secret 1010101010 -name “test\_1” -webSocket -workDir “c:\jenkins”

This command works temporarily, but once I close the CMD window, the connection is lost.

Is there a recommended way to keep the Jenkins agent running or start it automatically without keeping CMD open?

Any advice would be greatly appreciated.

---

<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:** [June 24, 2025, 3:52pm UTC](https://community.jenkins.io/t/jenkins-agent-auto-start-on-windows-without-keeping-cmd-open/33178/2 "2025-06-24T15:52:31Z")

</div>

You can install the agent as a service (there is a menu option in the GUI of the agent process to do so). One thing to note is that if you need the jobs to interact with the desktop at all, running as a service will not work. Services are not allowed to interact with the desktop.

---

<div class="post-metadata">

**Author:** ![siro2029](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@siro2029](https://community.jenkins.io/u/siro2029)\
**Post date:** [June 24, 2025, 11:44pm UTC](https://community.jenkins.io/t/jenkins-agent-auto-start-on-windows-without-keeping-cmd-open/33178/3 "2025-06-24T23:44:05Z")

</div>

Thank you for your response.

I was hoping to run the agent under a specific user context, so I understand that running it as a service would not be suitable in that case—especially if the job needs to interact with the desktop.

Does this mean that the only option is to keep the command prompt window open if I want to run the agent interactively under a user session?

---

<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:** [June 25, 2025, 3:50pm UTC](https://community.jenkins.io/t/jenkins-agent-auto-start-on-windows-without-keeping-cmd-open/33178/4 "2025-06-25T15:50:55Z")

</div>

Yes, that is correct.

---

<div class="post-metadata">

**Author:** ![kon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/kon/32/1197_2.png) [@kon](https://community.jenkins.io/u/kon)\
**Post date:** [June 30, 2025, 6:16am UTC](https://community.jenkins.io/t/jenkins-agent-auto-start-on-windows-without-keeping-cmd-open/33178/5 "2025-06-30T06:16:25Z")

</div>

> java -jar agent.jar -url [http://10.10.10.10:8080/](http://10.10.10.10:8080/) -secret 1010101010 -name “test\_1” -webSocket -workDir “c:\jenkins”

IIRC if you use `javaw` rather than `java`, then Windows doesn’t open a console window, but the process will still be able to interact with the desktop. I haven’t tried running Jenkins agents in this way though.

In the CreateProcess API, there are also options to start a console application (such as `java.exe`) without a console, or with a hidden console window. The latter seems to be surfaced in PowerShell as `Start-Process -WindowStyle:Hidden`.

You mention ”auto-start” in the thread title. Apart from services and shortcuts, you can also set up auto-start as a _scheduled task_ that starts when a specific user logs in, and that can be configured to allow interacting with the user’s desktop.
