How to install WindowsService?

 

To install WindowsService you can use the follow ‘bat’ code:

@ECHO OFF

 

REM The following directory is for .NET 2.0

set DOTNETFOLDER=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727

set PATH=%PATH%;%DOTNETFOLDER%

 

echo Installing your Service...

echo ---------------------------------------------------

InstallUtil /i ServiceFile.exe

echo ---------------------------------------------------

echo Done.

You have to create the .bat file and locate it in your application folder. the “ServiceFile.exe” you have to replace on yours application file name.

IMPORTENT! To run this code on Vista you have to run the code as administrator.

 

The uninstall code look like this:

@ECHO OFF

 

REM The following directory is for .NET 2.0

set DOTNETFOLDER=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727

set PATH=%PATH%;%DOTNETFOLDER%

 

echo Uninstalling your Service...

echo ---------------------------------------------------

InstallUtil /u ServiceFile.exe

echo ---------------------------------------------------

echo Done.

Leave a Reply

Your email address will not be published. Required fields are marked *