how to display startup error message in windows service?

James Joshua Street

So I wanted to create a windows service that runs a few commands in a batch file.

However, while I assume I can redirect stdout from the subprocess and read out an error message, I can't seem to find out how I would get that to display to the screen.

when starting a windows service, it gives errors when the service fails to start, so ideally I would like to just use the interface that pops up the other service errors rather than popping up some window of my own or writing a log file.

I used this to get started but it doesn't seem to have anything on error processing.

http://www.codeproject.com/Articles/499465/Simple-Windows-Service-in-Cplusplus

He just outputs to a debugger. I can definitely do that, but ideally the person starting the service would want to know if there was an error starting.

Remy Lebeau

Yes, you can redirect the STDOUT of the spawned process. MSDN has an article on that topic:

Creating a Child Process with Redirected Input and Output

You can use ReportEvent(), EventWrite(), or TraceEvent() to write log messages to the System Event Log (which is located within Windows' Control Panel), depending on which logging API you decide to use. Refer to MSDN for more details:

Event Logging

Windows Event Log

A service is a background task, it should not display its own UIs. Use the system Event Viewer to view log messages. The popup the user sees if the service fails to start is not displayed by the service itself, but by the Service Control Manager.

Starting with Windows Vista, services do not run in the same desktop session as logged in users (Session 0 Isolation), so they cannot display their own UI anymore. If your service must display a popup message, it can use WTSSendMessage() for that. For more complex UIs, it is best to implement that as a separate non-service GUI app that runs in the user's session, and then the service can launch/communicate with that app as needed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to display the error message

From Dev

How to run Ubuntu service on Windows (at startup)?

From Dev

How to display the error message for DataAnnotations

From Dev

how to display openerp error message

From Dev

How to display error message as a modal

From Dev

How to display a message on startup about new feature only to pervious users

From Dev

Error message in terminal on startup

From Dev

Error message at startup

From Dev

Display custom error message from a liferay hook service after an exception

From Dev

How to return error message in a IBM BPM service?

From Dev

How to display error message in an Eclipse RCP wizard?

From Dev

How to display an error message within the form

From Dev

how to display error message next to textbox in javascript?

From Dev

How to display different error message with Python functions

From Dev

How to validate and display error for git commit message?

From Dev

How to display error message instead of java exception?

From Dev

How to display an error message over a field

From Dev

How to display the multiple error message for a single CustomValidator

From Dev

How to display an error message within the form

From Dev

How to display the jquery validation error message in popup?

From Dev

How to start a service at startup

From Dev

Windows Service "Timeout" instantly on startup

From Dev

Windows Service "Timeout" instantly on startup

From Dev

As the service object to display a message in the view

From Dev

As the service object to display a message in the view

From Dev

Login display error message

From Dev

Display a separate error message

From Dev

How to suppress R startup message?

From Dev

How do I display a message on login for Windows 8/8.1?

Related Related

  1. 1

    How to display the error message

  2. 2

    How to run Ubuntu service on Windows (at startup)?

  3. 3

    How to display the error message for DataAnnotations

  4. 4

    how to display openerp error message

  5. 5

    How to display error message as a modal

  6. 6

    How to display a message on startup about new feature only to pervious users

  7. 7

    Error message in terminal on startup

  8. 8

    Error message at startup

  9. 9

    Display custom error message from a liferay hook service after an exception

  10. 10

    How to return error message in a IBM BPM service?

  11. 11

    How to display error message in an Eclipse RCP wizard?

  12. 12

    How to display an error message within the form

  13. 13

    how to display error message next to textbox in javascript?

  14. 14

    How to display different error message with Python functions

  15. 15

    How to validate and display error for git commit message?

  16. 16

    How to display error message instead of java exception?

  17. 17

    How to display an error message over a field

  18. 18

    How to display the multiple error message for a single CustomValidator

  19. 19

    How to display an error message within the form

  20. 20

    How to display the jquery validation error message in popup?

  21. 21

    How to start a service at startup

  22. 22

    Windows Service "Timeout" instantly on startup

  23. 23

    Windows Service "Timeout" instantly on startup

  24. 24

    As the service object to display a message in the view

  25. 25

    As the service object to display a message in the view

  26. 26

    Login display error message

  27. 27

    Display a separate error message

  28. 28

    How to suppress R startup message?

  29. 29

    How do I display a message on login for Windows 8/8.1?

HotTag

Archive