Install Window Service Programmatically

First implement the window service and build it. Your output will be create in the debug/release folder as an exe. Now to install window service on machine, do the following –

Download .cs file from following location

Write following code to install the service –

string ServiceName = “TestWindowService”;

string ServiceDisplayName = “TestWindowService”;

string ServiceExePath = @”C:\TestWindowService\Debus\TestWindowService.exe”;

ServiceTools.ServiceInstaller.InstallAndStart(ServiceName, ServiceDisplayName, ServiceExePath);

Write following code to UnInstall the service –

string ServiceName = “TestWindowService”;

//Check if serice is installed

if (ServiceTools.ServiceInstaller.ServiceIsInstalled(ServiceName))


//Uninstall Service




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: