If you want to write a
winserv-based service in a scripting language other than TCL, you may want to implement helper modules, similar to TCL winserv support package. To do it, you have to know what escape sequences winserv interprets when the application writes to its standard output or the named pipe.
Each string that winserv will parse must be terminated by a newline. If you use escape sequences, you must put each sequence on a line by itself.
\033 a | accept/deny control codes: |
\033 a p | accept pause/continue control codes |
\033 a c | accept PARAMCHANGE |
\033 a s | accept SHUTDOWN |
\033 a n | accept NETBIND... codes |
\033 a r | reset; accept STOP and nothing more |
\033 a P | don't accept pause/continue |
\033 a C | don't accept PARAMCHANGE |
\033 a S | don't accept SHUTDOWN |
\033 a N | don't accept NETBIND... codes |
\033 s | set service status |
\033 s p | the service is now paused |
\033 s P | the service is going to pause (PAUSE_PENDING) |
\033 s C | the service is going to continue (CONTINUE_PENDING) |
\033 s r | the service is running |
\033 s S | the service is going to stop (STOP_PENDING) |
\033 e | add message to the event log: |
\033 e i | at the information level |
\033 e e | at the error level |
\033 e s | at the success level |
\033 e w | at the warning level |
\033 e a | at the audit/success level |
\033 e A | at the audit/failure level |
For eventlog escapes, the message that will be added must follow the escape sequence on the same line. If the message contains embedded newlines, they must be replaced with \014 (form feed) control character.
When winserv receives a control code from the service manager, it sends a line to the application's standard input. The line is just a name like STOP or CONTINUE. You can get all possible names if you remove leading SERVICE_CONTROL_ from macros used for the ControlService function. For the user control codes (1
28–255), one of CODE128..CODE255 will be sent.