v0.1.5 Fixes
This commit is contained in:
parent
cc48f614be
commit
3d7ff9aac0
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
/.vs/
|
/.*/
|
||||||
/bin/
|
/bin/
|
||||||
/obj/
|
/obj/
|
||||||
/Properties/
|
/Properties/
|
||||||
|
@ -9,6 +9,7 @@ using WebmrAPI.Services;
|
|||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.AddWindowsService();
|
||||||
builder.Services.Configure<AppSettings>(builder.Configuration);
|
builder.Services.Configure<AppSettings>(builder.Configuration);
|
||||||
builder.Services.AddLogging(config =>
|
builder.Services.AddLogging(config =>
|
||||||
{
|
{
|
||||||
|
103
install.bat
Normal file
103
install.bat
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
@echo off
|
||||||
|
REM install.bat - Script for installing/uninstalling ProcessMonitoringService on the target machine.
|
||||||
|
REM
|
||||||
|
REM --- Run as Administrator ---
|
||||||
|
REM This script must be run with administrator privileges to create and manage Windows services.
|
||||||
|
REM If the script is not run as administrator, it will attempt to restart itself with elevated privileges.
|
||||||
|
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
REM Check if the script is running with administrator privileges
|
||||||
|
NET SESSION >NUL 2>&1
|
||||||
|
IF %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo.
|
||||||
|
echo This script must be run with administrator privileges.
|
||||||
|
echo Attempting to restart with elevated privileges...
|
||||||
|
echo.
|
||||||
|
powershell -Command "Start-Process -FilePath '%~dpnx0' -Verb RunAs"
|
||||||
|
exit /b
|
||||||
|
)
|
||||||
|
|
||||||
|
echo Script is running with administrator privileges.
|
||||||
|
|
||||||
|
REM --- Service Settings ---
|
||||||
|
SET "SERVICE_NAME=ProcessMonitoringService"
|
||||||
|
SET "SERVICE_DISPLAY_NAME=Process Monitoring Service"
|
||||||
|
SET "SERVICE_DESCRIPTION=A service for detailed monitoring processes and memory regions."
|
||||||
|
|
||||||
|
REM The service executable is in the same directory as install.bat
|
||||||
|
SET "SERVICE_EXE_PATH=%~dp0%SERVICE_NAME%.exe"
|
||||||
|
|
||||||
|
REM --- Options ---
|
||||||
|
SET "ACTION=%1"
|
||||||
|
IF "%ACTION%"=="" SET "ACTION=install"
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo --- Executing action: %ACTION% ---
|
||||||
|
echo.
|
||||||
|
|
||||||
|
IF /I "%ACTION%"=="install" GOTO :INSTALL
|
||||||
|
IF /I "%ACTION%"=="uninstall" GOTO :UNINSTALL
|
||||||
|
|
||||||
|
echo Unknown action: "%ACTION%".
|
||||||
|
echo Usage:
|
||||||
|
echo %~nx0 install - Creates and starts the service.
|
||||||
|
echo %~nx0 uninstall - Stops, deletes the service. After this, manually delete the folder.
|
||||||
|
GOTO :END
|
||||||
|
|
||||||
|
:INSTALL
|
||||||
|
echo --- Step 1: Create Windows Service ---
|
||||||
|
echo Creating service "%SERVICE_DISPLAY_NAME%" (%SERVICE_NAME%)...
|
||||||
|
IF NOT EXIST "%SERVICE_EXE_PATH%" (
|
||||||
|
echo ERROR: Service executable not found: "%SERVICE_EXE_PATH%".
|
||||||
|
GOTO :END
|
||||||
|
)
|
||||||
|
|
||||||
|
sc create "%SERVICE_NAME%" binPath="\"%SERVICE_EXE_PATH%\"" DisplayName="%SERVICE_DISPLAY_NAME%" start= auto
|
||||||
|
IF %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo ERROR: Failed to create service. A service with this name might already exist or you lack permissions.
|
||||||
|
GOTO :END
|
||||||
|
)
|
||||||
|
echo Service created successfully.
|
||||||
|
|
||||||
|
echo --- Step 2: Set Service Description ---
|
||||||
|
sc description "%SERVICE_NAME%" "%SERVICE_DESCRIPTION%"
|
||||||
|
IF %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo WARNING: Failed to set service description.
|
||||||
|
)
|
||||||
|
|
||||||
|
echo --- Step 3: Start Service ---
|
||||||
|
echo Starting service "%SERVICE_NAME%"...
|
||||||
|
sc start "%SERVICE_NAME%"
|
||||||
|
IF %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo ERROR: Failed to start service. Check service logs.
|
||||||
|
GOTO :END
|
||||||
|
)
|
||||||
|
echo Service started successfully.
|
||||||
|
GOTO :END
|
||||||
|
|
||||||
|
:UNINSTALL
|
||||||
|
echo --- Stop Service ---
|
||||||
|
echo Stopping service "%SERVICE_NAME%"...
|
||||||
|
sc stop "%SERVICE_NAME%"
|
||||||
|
IF %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo WARNING: Failed to stop service. The service might not be running or you lack permissions.
|
||||||
|
)
|
||||||
|
|
||||||
|
echo --- Delete Windows Service ---
|
||||||
|
echo Deleting service "%SERVICE_NAME%"...
|
||||||
|
sc delete "%SERVICE_NAME%"
|
||||||
|
IF %ERRORLEVEL% NEQ 0 (
|
||||||
|
echo ERROR: Failed to delete service. The service might not exist or you lack permissions.
|
||||||
|
GOTO :END
|
||||||
|
)
|
||||||
|
echo Service deleted successfully.
|
||||||
|
|
||||||
|
echo For complete removal, please manually delete the folder from which install.bat was run.
|
||||||
|
GOTO :END
|
||||||
|
|
||||||
|
:END
|
||||||
|
echo.
|
||||||
|
echo Operation completed.
|
||||||
|
endlocal
|
||||||
|
pause
|
@ -26,5 +26,6 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user