Python Nssm 安装服务
1、下载Nssm
https://nssm.cc/download
2、手动安装
运行exe,选择启动的bat或者exe即可
然后去服务里启动
3、命令行安装
# -*- encoding=utf-8 -*- import os if __name__ == '__main__': pass service_name = 'my_service_name' display_name = 'my_display_name' description = 'my_description' bat_name = 'run.bat' # Uninstall service os.system('sc stop {}'.format(service_name)) os.system('sc delete {}'.format(service_name)) # install service os.system("nssm.exe install {} {}".format(service_name, bat_name)) os.system('nssm.exe set {} AppDirectory {}'.format(service_name, os.path.abspath(os.path.dirname(bat_name)))) os.system('nssm.exe set {} DisplayName {}'.format(service_name, display_name)) os.system('nssm.exe set {} Description {}'.format(service_name, description)) os.system('nssm.exe start {}'.format(service_name))