Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem for starting service #131

Open
SaeedSafi1999 opened this issue Jul 30, 2024 · 2 comments
Open

problem for starting service #131

SaeedSafi1999 opened this issue Jul 30, 2024 · 2 comments

Comments

@SaeedSafi1999
Copy link

SaeedSafi1999 commented Jul 30, 2024

I complete my code following your ping service code example but when I want to start service return windows error:1053
The service is not responding to the control function.
how to fix that?

@faern
Copy link
Member

faern commented Oct 28, 2024

If this is still a problem, can you provide more information? For example code where this happens? It sounds like your code fails to return in a timely manner and report back to Windows that it started successfully?

Does the ping example work for you, but not your program? Then can you try massaging them until you figure out where the difference is?

@Jackolix
Copy link

i have a similar Problem when starting my windows service I created. The service is created but cannot be started from the rust program itself. What did i wrong?

ERROR: IO error in winapi call

#[cfg(windows)]
async fn setup_service() -> windows_service::Result<()> {
    use std::ffi::OsString;
    use windows_service::{
        service::{ServiceAccess, ServiceErrorControl, ServiceInfo, ServiceStartType, ServiceType},
        service_manager::{ServiceManager, ServiceManagerAccess},
    };

    let manager_access = ServiceManagerAccess::CONNECT | ServiceManagerAccess::CREATE_SERVICE;
    let service_manager = ServiceManager::local_computer(None::<&str>, manager_access)?;

    let service_binary_path = Path::new(INSTALL_DIR).join(EXE_NAME);

    let service_info = ServiceInfo {
        name: OsString::from("Installer"),
        display_name: OsString::from("Installer Service"),
        service_type: ServiceType::OWN_PROCESS,
        start_type: ServiceStartType::AutoStart,
        error_control: ServiceErrorControl::Normal,
        executable_path: service_binary_path,
        launch_arguments: vec![],
        dependencies: vec![],
        account_name: None,
        account_password: None,
    };

    let service = service_manager.create_service(&service_info, ServiceAccess::CHANGE_CONFIG)?;
    service.set_description("Interface")?;
    service.start(&[OsStr::new("Init start from Installer")])?; // Error happens here
    Ok(())
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants