views:

262

answers:

4

I have a problem with a service. I have an installed application that runs as a service; when I start that service, a command prompt opens and immediately closes. The program isn't executing properly and I need to see the error output but the command prompt closes too quickly. Is there a way to force the window to remain open? Thanks everyone!

A: 

Since a service doesn't allow for user-interaction, could you instead redirect your message to stderr or a file? Or post something to the Event Viewer?

Michael Todd
+1  A: 

Put a PAUSE in the batchfile.

MyApp.exe
PAUSE

That's all

ComponentBuilder
A: 

If the service doesn't keep it's own log file, there might be an error visible in the Event Log on that machine. You can open the EventViewer from the Control Panel / Administrative Tools section.

Ron Savage
+1  A: 

Services cannot create console windows, they run in their own session with their own "desktop". Given that you see one, I'd have to guess that you didn't actually create a service. What happened when you tried to install it with InstallUtil.exe?

This MSDN Library page has recommendations to debug a service's OnStart() method.

Hans Passant