Once your Service and Worker classes are complete, compile the project to get your service EXE.
To install the service on a PC you can use the .NET frameworks tool InstallUtil.exe, found in the frameworks system directory.
You can copy the code listed here into a BAT file for simple DOS installation.
To uninstall just put a –U flag after the InstallUtil.exe call
(i.e. %FIRSTPART%%DOTNETVER%%SECONDPART% -U %PROG%).
[DOS]
@echo off
SET PROG="C:\EmptyService.exe"
SET FIRSTPART=%WINDIR%"\Microsoft.NET\Framework\v"
SET SECONDPART="\InstallUtil.exe"
SET DOTNETVER=2.0.50727
IF EXIST %FIRSTPART%%DOTNETVER%%SECONDPART% GOTO install
SET DOTNETVER=1.1.4322
IF EXIST %FIRSTPART%%DOTNETVER%%SECONDPART% GOTO install
SET DOTNETVER=1.0.3705
IF EXIST %FIRSTPART%%DOTNETVER%%SECONDPART% GOTO install
GOTO fail
:install
ECHO Found .NET Framework version %DOTNETVER%
ECHO Installing service %PROG%
%FIRSTPART%%DOTNETVER%%SECONDPART% %PROG%
GOTO end
:fail
echo FAILURE -- Could not find .NET Framework install
:end
ECHO DONE!!!
Pause
Some deployment hints:
- Elevate NTFS on the service EXE file to ensure it is not replaced by another similar named exe which will now run under the configured security context.
- To avoid a reboot after install/uninstall unlock resources used by your service, which includes closing files, closing the Windows Service Manager, etc. Sometimes adding an IISRESET line to the install script is helpful.
|
Now your service is installed. Start it and Stop it from the Service Manager and use the Event Log Viewer to view its output.