You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
992 B
Batchfile

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

::使用SC命令安装成Windows服务
::===================================
::请求管理员省份运行,可以删除
@echo off
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
:: 请求管理员权限...
echo "Request to run with administrator privileges......"
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
::===================================
echo %cd%
:: 创建Windows服务
sc create DockerStudy.WebApi.Service binpath= "%cd%\..\DockerStudyApi.exe" start= auto
:: 设置服务的描述字符串
sc description DockerStudy.WebApi.Service "DockerStudy.WebApi 服务."
:: 启动服务
sc start "DockerStudy.WebApi.Service"
pause