Skip to content

Instantly share code, notes, and snippets.

@glego
Created February 19, 2022 20:46
Show Gist options
  • Save glego/bea67ae5c2a490564ffbc13b14089baa to your computer and use it in GitHub Desktop.
Save glego/bea67ae5c2a490564ffbc13b14089baa to your computer and use it in GitHub Desktop.
@echo off
IF "%NGINX_DIR%"=="" SET NGINX_DIR=%~dp0
set "params=%*"
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~dp0"" && ""%~0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
echo Installing %NGINX_DIR%nginx.exe
nssm install nginx "%NGINX_DIR%nginx.exe"
nssm set nginx AppDirectory %NGINX_DIR%
nssm set nginx DisplayName nginx
nssm set nginx Start SERVICE_AUTO_START
nssm set nginx ObjectName LocalSystem
nssm set nginx Type SERVICE_WIN32_OWN_PROCESS
nssm set nginx AppPriority NORMAL_PRIORITY_CLASS
nssm set nginx AppNoConsole 0
nssm set nginx AppAffinity All
nssm set nginx AppStopMethodSkip 0
nssm set nginx AppStopMethodConsole 1500
nssm set nginx AppStopMethodWindow 1500
nssm set nginx AppStopMethodThreads 1500
nssm set nginx AppThrottle 1500
nssm set nginx AppExit Default Restart
nssm set nginx AppRestartDelay 1500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment