WindowService has a property called “Path to Executable” . This property contains path of window service that is going to execute. When you need this path in .NET Application there is no direct way to do it . You can not get it either via ServiceControler or any other way.
To get that you need to read Registry. All information about all window service installed on machine storead at following location.
C# Code to read Service Registry.
RegistryKey services = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services");
if (services != null)
object pathtoexecutable = services.OpenSubKey(<<ServiceName>>).GetValue("ImagePath");
In Above code replace <<ServiceName>> with your service name.
Also this is a registry operation so you need proper permission to read registry and apply any other registry operation at your own risk.
Give your comment or any new idea about this task.