开发者

Command Prompt Closes Too Fast After Running A Service

开发者 https://www.devze.com 2022-12-16 15:58 出处:网络
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 a

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 comman开发者_如何学Cd prompt closes too quickly. Is there a way to force the window to remain open? Thanks everyone!


Put a PAUSE in the batchfile.

MyApp.exe
PAUSE

That's all


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.


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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消