Skip to content

Add support for running a service exe as a console app. #3641

@Type1J

Description

@Type1J

Suggestion

All of the Windows services that I've ever written in C or C++ could be run as a console application for one reason or another.

The windows-services crate could easily allow this functionality, and already detects if the process was started as a console app:

if unsafe { StartServiceCtrlDispatcherW(table.as_ptr()) } == 0 {

There's more than 1 way to add this feature, but I think that there is 1 way that breaks the least: Add a .allow_console() (or choose a better name) to Service that when called allows .run() to return if the check on the call to StartServiceCtrlDispatcherW() (linked above) sees that it was run on the console. If the .allow_console() function is never called, then keep the existing functionaility.

The state in Service is all private, so adding to it would only affect code in the same file, but a bit in the existing u32 could be used, if that's acceptable.

Please add this functionality, as I can't use it without this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions