/* Don't expand parameters when retrieving for the GUI. */\r
bool expand = si ? true : false;\r
\r
+ /* Try to get environment variables - may fail */\r
+ get_environment(service->name, key, NSSM_REG_ENV, &service->env, &service->envlen);\r
+ /* Environment variables to add to existing rather than replace - may fail. */\r
+ get_environment(service->name, key, NSSM_REG_ENV_EXTRA, &service->env_extra, &service->env_extralen);\r
+\r
+ /* Set environment if we are starting the service. */\r
+ if (si) set_service_environment(service);\r
+\r
/* Try to get executable file - MUST succeed */\r
if (get_string(key, NSSM_REG_EXE, service->exe, sizeof(service->exe), expand, false, true)) {\r
RegCloseKey(key);\r
}\r
}\r
\r
- /* Try to get environment variables - may fail */\r
- get_environment(service->name, key, NSSM_REG_ENV, &service->env, &service->envlen);\r
- /* Environment variables to add to existing rather than replace - may fail. */\r
- get_environment(service->name, key, NSSM_REG_ENV_EXTRA, &service->env_extra, &service->env_extralen);\r
-\r
/* Try to get priority - may fail. */\r
unsigned long priority;\r
if (get_number(key, NSSM_REG_PRIORITY, &priority, false) == 1) {\r