How to Set Up Python as a Service on Windows?

Estimated read time 2 min read

To set up Python as a service on Windows, you need to follow these steps:

  1. Download and install NSSM (Non-Sucking Service Manager) from
  2. Open a command prompt as an administrator.
  3. Navigate to the directory where nssm.exe is located using the cd command.
  4. Use the following command to create a new service:
nssm install <service-name>

Note: Replace <service-name> with the name you want to give your service.

  1. In the NSSM GUI, specify the following settings:
  • Application path: Enter the path to your Python executable, followed by the path to your script. For example: C:\Python39\python.exe C:\path\to\your\
  • Startup directory: Enter the path to the directory where your script is located.
  • Arguments: Enter any arguments that your script requires.
  • Log file path: Enter the path to the log file you want to use for your service. This is optional, but recommended.
  • Restart tab: Configure the restart settings for your service as desired.
  1. Click on the “Install service” button to create the service.
  2. Start the service using the following command:
net start <service-name>

Note: Replace <service-name> with the name of your service.

That’s it! Your Python script should now be running as a service on your Windows machine. You can view the status of your service using the Windows Services console.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply