I created an application as a Windows Service which works fine on my workstation running Windows 8 x64, and writes several events in the Application eventlog on OnStart(). I used InstallUtil to install it on a Windows 2012 machine and it stops right after it starts. The only thing I see regarding it in the eventlog is under System:
The Foo service entered the stopped state.
EDIT 1: why would you downvote the question without even leaving a remark as to why it's bad?
Few things I have learned on debugging windows services that might help you in troubleshooting your issue.
Try to catch UnhandledException before the service exits by adding an event handler to the appdomain. I have my Log function that writes to text file.
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException
Public Sub CurrentDomain_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs)
'Log and output exception message before the application exits.
Dim exp = DirectCast(e.ExceptionObject, Exception)
Dim formatexp = String.Format("Exception: {0}; Message: {1}: InnerException: {2}",
exp.ToString(),
exp.Message.ToString(),
exp.InnerException.ToString())
Log(formatexp)
Console.WriteLine(formatexp)
Log("Application exited due to unhandled exception")
Console.WriteLine("Service exited due to unhandled exception")
'Exit the batch process gracefully.
Environment.Exit(-1)
End Sub
Try using WindDbg for debugging Windows Service Crash or Hang issues and you can download it from Microsoft Download site.
Check if service account that is trying to access any resource on the server has access to them.
If you want to see real time execution of your code then log execution to a SignalR Host. This might be overkill but I once had multiple threads executing different processes and I was able to debug an issue using SignalR.
Note: If you can post some sample code then it would be helpful to us in helping you out.