X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=registry.cpp;h=3410e4af9efad2f0217a256f883652e00c8407ef;hb=c03d51cbbfe9f4f8a28dbabbfc068573a1842b74;hp=50f6dc3500627b25145f43ab59cb37cda1cbac2b;hpb=77855b77fa52ac6e844377a191c2ae836a32b5bd;p=nssm.git diff --git a/registry.cpp b/registry.cpp index 50f6dc3..3410e4a 100644 --- a/registry.cpp +++ b/registry.cpp @@ -119,6 +119,8 @@ int create_parameters(nssm_service_t *service, bool editing) { else if (editing) RegDeleteValue(key, NSSM_REG_ROTATE_BYTES_LOW); if (service->rotate_bytes_high) set_number(key, NSSM_REG_ROTATE_BYTES_HIGH, service->rotate_bytes_high); else if (editing) RegDeleteValue(key, NSSM_REG_ROTATE_BYTES_HIGH); + if (service->no_console) set_number(key, NSSM_REG_NO_CONSOLE, 1); + else if (editing) RegDeleteValue(key, NSSM_REG_NO_CONSOLE); /* Environment */ if (service->env) { @@ -466,67 +468,6 @@ int get_parameters(nssm_service_t *service, STARTUPINFO *si) { /* 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); - if (si) { - if (service->env_extra) { - TCHAR *env; - unsigned long envlen; - - /* Copy our environment for the application. */ - if (! service->env) { - TCHAR *rawenv = GetEnvironmentStrings(); - env = rawenv; - if (env) { - /* - The environment block starts with variables of the form - =C:=C:\Windows\System32 which we ignore. - */ - while (*env == _T('=')) { - for ( ; *env; env++); - env++; - } - envlen = 0; - if (*env) { - while (true) { - for ( ; env[envlen]; envlen++); - if (! env[++envlen]) break; - } - envlen++; - - service->envlen = envlen * sizeof(TCHAR); - service->env = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, service->envlen); - memmove(service->env, env, service->envlen); - FreeEnvironmentStrings(rawenv); - } - } - } - - /* Append extra variables to configured variables. */ - if (service->env) { - envlen = service->envlen + service->env_extralen - sizeof(TCHAR)/*?*/; - env = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, envlen); - if (env) { - memmove(env, service->env, service->envlen - sizeof(TCHAR)); - /* envlen is in bytes but env[i] is in characters. */ - memmove(env + (service->envlen / sizeof(TCHAR)) - 1, service->env_extra, service->env_extralen); - - HeapFree(GetProcessHeap(), 0, service->env); - HeapFree(GetProcessHeap(), 0, service->env_extra); - service->env = env; - service->envlen = envlen; - } - else log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_OUT_OF_MEMORY, _T("environment"), _T("get_parameters()"), 0); - } - else { - /* Huh? No environment at all? */ - service->env = service->env_extra; - service->envlen = service->env_extralen; - } - } - - service->env_extra = 0; - service->env_extralen = 0; - } - /* Try to get priority - may fail. */ unsigned long priority; if (get_number(key, NSSM_REG_PRIORITY, &priority, false) == 1) { @@ -550,6 +491,9 @@ int get_parameters(nssm_service_t *service, STARTUPINFO *si) { if (get_number(key, NSSM_REG_ROTATE_BYTES_LOW, &service->rotate_bytes_low, false) != 1) service->rotate_bytes_low = 0; if (get_number(key, NSSM_REG_ROTATE_BYTES_HIGH, &service->rotate_bytes_high, false) != 1) service->rotate_bytes_high = 0; + /* Try to get force new console setting - may fail. */ + if (get_number(key, NSSM_REG_NO_CONSOLE, &service->no_console, false) != 1) service->no_console = 0; + /* Change to startup directory in case stdout/stderr are relative paths. */ TCHAR cwd[PATH_LENGTH]; GetCurrentDirectory(_countof(cwd), cwd);