Skip to main content

Command Palette

Search for a command to run...

Self Hosted Agent as Service

Updated
2 min read
Self Hosted Agent as Service
  • Open PowerShell as an administrator.

  • Navigate to the directory where your self-hosted agent is located. You mentioned that you go to the agent folder and run ./run.cmd, so navigate to that directory using the cd command.

  • Once you are in the agent directory, you can install the agent as a Windows service using the following command:

      powershell
    
  •   .\config.cmd service install
    
  • This command will install your self-hosted agent as a Windows service, and it will start automatically when the computer is restarted.

  • To verify the service installation and ensure it's set to start automatically, you can use the following command to configure the service:

      powershell
    
  •   sc config "YourAgentServiceName" start=auto
    

    Replace "YourAgentServiceName" with the actual name of your agent service, which is typically the default name unless you specified a different name during the agent setup. This command sets the service to start automatically.

  • You can now start the service manually for the current session using the sc command:

      powershell
    
  1.  sc start "YourAgentServiceName"
    

    Again, replace "YourAgentServiceName" with the actual name of your agent service.

Now, your self-hosted agent should be set up as a Windows service and will automatically start whenever the computer is restarted. Make sure to replace "YourAgentServiceName" with the actual name of your agent service, which you can verify in the Windows Services tool.

More from this blog

DevOps Journey with M Hassan

174 posts

I am writing these blogs because I recently completed a comprehensive DevOps course where I gained in-depth knowledge of the topics mentioned. As I progressed through the course, I realized the importance of having a concise and accessible resource to revise and reinforce my understanding of each topic. Therefore, I decided to create cheat sheets in the form of blog posts. These cheat sheets will not only serve as a handy reference for myself but also benefit others who are also interested in mastering DevOps concepts. By documenting each topic and providing concise explanations, I aim to create a valuable resource that simplifies complex concepts and facilitates hands-on practice. This way, I can solidify my own understanding while helping others on their DevOps journey.