45 lines
850 B
Batchfile
45 lines
850 B
Batchfile
@echo off
|
|
|
|
:: Set to current Dictionary
|
|
cd /d "%~dp0"
|
|
|
|
:: File name to look for
|
|
set "FILE_NAME=HRServer.exe"
|
|
|
|
:: Path for the server (in "Server")
|
|
set "SEARCH_PATH=%~dp0Server"
|
|
|
|
:: Search within "Server"
|
|
for /f "delims=" %%F in ('dir /b /s "%SEARCH_PATH%\%FILE_NAME%" 2^>nul') do (
|
|
set "FULL_PATH=%%F"
|
|
goto :FOUND
|
|
)
|
|
|
|
:: If no file was found
|
|
echo File "%FILE_NAME%" was not found
|
|
pause
|
|
exit /b 1
|
|
|
|
:FOUND
|
|
:: Name des Dienstes
|
|
set "SERVICE_NAME=HRServer"
|
|
|
|
:: Create service
|
|
sc create "%SERVICE_NAME%" binPath= "\"%FULL_PATH%\"" start= auto
|
|
if %errorlevel% neq 0 (
|
|
echo Error creating a service!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
:: Start service
|
|
sc start "%SERVICE_NAME%"
|
|
if %errorlevel% neq 0 (
|
|
echo Error starting the service!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo The service "%SERVICE_NAME%" was created successfully and started.
|
|
pause
|
|
exit /b 0
|