最近在win10上配置了gitea的服务。官方给出的注册gitea为服务的方法是使用sc命令注册为服务
不过,他给出的命令是cmd下的,现在windows已经默认用powershell了。有需要调整的地方
cmd
sc create gitea start= auto binPath= "\"C:\gitea\gitea.exe\" web --config \"C:\gitea\custom\conf\app.ini\""
powershell
sc create gitea start= auto binPath= "D:\coding\gitea\gitea.exe web --config D:\coding\gitea\custom\conf\app.ini"
关于这个命令的使用,可以查看微软官方的文档
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-create
其中删除服务的命令是
sc delete gitea
使用powershell创建服务
powershell还是比较好用的,有New-Service,Stop-Service,Start-Service等等几个命令
注意BinaryPathName里面的路径如果包含空格,需要用引号括起来,路径里面可以包含启动服务的参数
New-Service -Name "TestService" -BinaryPathName '"C:\WINDOWS\System32\svchost.exe -k netsvcs"'
创建包含说明、启动类型和显示名称的服务
$params = @{
Name = "TestService"
BinaryPathName = '"C:\WINDOWS\System32\svchost.exe -k netsvcs"'
DependsOn = "NetLogon"
DisplayName = "Test Service"
StartupType = "Manual"
Description = "This is a test service."
}
New-Service @params
网友评论