user1240679 user1240679 -4 years ago 137
C# Question

Windows service not showing up in installed services (and hence unable to start)

I just built a very simple Windows service to test something and built it to get the .exe. As per this article in MSDN, I also installed the service using the Visual Studio Command Prompt 2010 (ran as administrator)

installutil TestService.exe
.

When using the
installutil
command, everything runs fine and I get a message saying that the service has been installed. Further, to start the service when I check inside the Services node (in Server Explorer in Visual Studio), I do not see any service named
TestService.exe
.

Also, Start Menu -> My Computer (Right Click) -> Manage -> Services and Application -> Services does not show the
TestService.exe
through which I could start the service.

Any suggestions how do I start the service?

Code inside
OnStart
function:

Process[] testProcess = Process.GetProcessesByName("notepad.exe");
if (testProcess.Length == 0)
File.WriteAllText(@"C:\Users\User1\Desktop\service.txt", "nothing");

else
File.WriteAllText(@"C:\Users\User1\Desktop\service.txt", "run");

Answer Source

I have had problems with installutil before and found using the sc command works whereas installutil didn't.

Try installing your service with this command:

sc create servicename binPath= serviceexe.exe
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download