X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=registry.cpp;h=de3127fc9ca8428699430d4d4eacd222683d74d5;hb=32a1d0fab47a050086106aac346342c70f4d985b;hp=00d6eafa857a3df1e4ccf9d920e8e9accee889ca;hpb=2f2f64b07611fe0709bf4d502de7cac292dc1975;p=nssm.git diff --git a/registry.cpp b/registry.cpp index 00d6eaf..de3127f 100644 --- a/registry.cpp +++ b/registry.cpp @@ -531,6 +531,14 @@ int get_parameters(nssm_service_t *service, STARTUPINFO *si) { /* Don't expand parameters when retrieving for the GUI. */ bool expand = si ? true : false; + /* Try to get environment variables - may fail */ + get_environment(service->name, key, NSSM_REG_ENV, &service->env, &service->envlen); + /* Environment variables to add to existing rather than replace - may fail. */ + get_environment(service->name, key, NSSM_REG_ENV_EXTRA, &service->env_extra, &service->env_extralen); + + /* Set environment if we are starting the service. */ + if (si) set_service_environment(service); + /* Try to get executable file - MUST succeed */ if (get_string(key, NSSM_REG_EXE, service->exe, sizeof(service->exe), expand, false, true)) { RegCloseKey(key); @@ -585,11 +593,6 @@ int get_parameters(nssm_service_t *service, STARTUPINFO *si) { } } - /* Try to get environment variables - may fail */ - get_environment(service->name, key, NSSM_REG_ENV, &service->env, &service->envlen); - /* Environment variables to add to existing rather than replace - may fail. */ - get_environment(service->name, key, NSSM_REG_ENV_EXTRA, &service->env_extra, &service->env_extralen); - /* Try to get priority - may fail. */ unsigned long priority; if (get_number(key, NSSM_REG_PRIORITY, &priority, false) == 1) {