windows-service-rs icon indicating copy to clipboard operation
windows-service-rs copied to clipboard

Make a runnable example

Open Xyndra opened this issue 1 year ago • 1 comments

All of the examples are sami-dependent and it is impossible to know how to combine them. Please make one working example that you can just copy and run.

Xyndra avatar Feb 03 '23 17:02 Xyndra

Examples we have cover various aspects of windows services from registration to implementation and supervision.

  • install_service.rs shows how to register a service.
  • uninstall_service.rs shows how to unregister a service.
  • ping_service.rs is a demo of a simple windows service that continuously sends a message over UDP. It has to be registered with the system before you can start it. You can use install_service.rs to do that. This is outlined in the header comment in ping_service.rs.
  • service_config.rs shows how to query arbitrary service configuration.
  • service_failure_actions.rs shows how to set up failure actions for an arbitrary service.
  • pause_continue.rs shows how to pause and resume an arbitrary service.

Also note that you don't need to copy and run things as cargo enables you to run cargo run --example <name>. Keep in mind that install_service.rs and uninstall_service.rs have to run with admin permissions, so you can build cargo build --examples under user shell first to make sure that all binaries are created under user account, and then run the executable under admin shell (i.e cargo run --example install_service)

If you think this is too confusing or you have a better idea how to either document that or re-arrange examples, then you are welcome to take a stab at it and perhaps make a pull request. We gladly accept contributions and improvements to this crate.

pronebird avatar Feb 06 '23 12:02 pronebird