mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-11 23:13:24 -05:00
Fix service startup handling
This commit is contained in:
parent
cf8b867165
commit
0e17b153a3
@ -226,8 +226,11 @@ DWORD Service::GetStartup() const
|
||||
|
||||
bool Service::ConfigureStartup(DWORD startup) {
|
||||
if(startup != GetStartup()) { // don't boost privs if we don't need to
|
||||
if (!::ChangeServiceConfig(m_sc_service, SERVICE_NO_CHANGE, startup, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
|
||||
return false;
|
||||
if(startup == SERVICE_AUTO_START) {
|
||||
return ExecHelper(_T("auto"));
|
||||
} else {
|
||||
return ExecHelper(_T("manual"));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define E_SVC_NORIGHTS 2
|
||||
#define E_SVC_CANTSTART 3
|
||||
#define E_SVC_CANTSTOP 4
|
||||
#define E_SVC_CANTCONFIG 5
|
||||
|
||||
// Global Variables:
|
||||
HINSTANCE hInst; // current instance
|
||||
@ -121,6 +122,17 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
retval = E_SVC_CANTSTOP;
|
||||
}
|
||||
}
|
||||
|
||||
if(strcmp(argv[1],"manual")) {
|
||||
if (!ChangeServiceConfig(svc, SERVICE_NO_CHANGE, SERVICE_DEMAND_START, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
|
||||
retval = E_SVC_CANTCONFIG;
|
||||
}
|
||||
|
||||
if(!strcmp(argv[1],"auto")) {
|
||||
if (!ChangeServiceConfig(svc, SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
|
||||
retval = E_SVC_CANTCONFIG;
|
||||
}
|
||||
|
||||
|
||||
CloseServiceHandle(svc);
|
||||
CloseServiceHandle(scm);
|
||||
|
Loading…
Reference in New Issue
Block a user