Use nssm instead of sc

This commit is contained in:
Hamza committed 2026-03-17 15:07:24 +01:00
1 parent 59ba823865
commit d05ba5cc55
5 files changed
+56 -11

No files matched your search

+24 -6
View File
@@ -1,23 +1,41 @@
@echo off
REM ===============================
REM DDNS Updater Install using NSSM
REM ===============================
REM Get the folder where this bat is located
SET SCRIPT_DIR=%~dp0
REM Define the service exe path (same folder as bat)
REM Define program and NSSM paths
SET EXE_NAME=DDNSUpdater.exe
SET EXE_PATH=%SCRIPT_DIR%%EXE_NAME%
SET NSSM_PATH=%SCRIPT_DIR%nssm.exe
REM Check if the exe exists
REM Check if files exist
IF NOT EXIST "%EXE_PATH%" (
echo ERROR: %EXE_NAME% not found in the same folder as this script.
pause
exit /b 1
)
REM Create the service (auto-start)
sc create DDNSUpdaterService binPath= "%EXE_PATH%" start= auto
IF NOT EXIST "%NSSM_PATH%" (
echo ERROR: nssm.exe not found in the same folder as this script.
pause
exit /b 1
)
REM Remove existing service if present
"%NSSM_PATH%" remove DDNSUpdaterService confirm
REM Install service
"%NSSM_PATH%" install DDNSUpdaterService "%EXE_PATH%"
REM Optional: auto-start at boot
"%NSSM_PATH%" set DDNSUpdaterService Start SERVICE_AUTO_START
REM Start the service
sc start DDNSUpdaterService
"%NSSM_PATH%" start DDNSUpdaterService
echo Service DDNSUpdaterService installed and started.
echo.
echo DDNSUpdaterService installed and started successfully!
pause