From: Iain Patterson Date: Tue, 28 Jan 2014 22:42:37 +0000 (+0000) Subject: Fixed argument parsing for setting ObjectName. X-Git-Tag: v2.22~25 X-Git-Url: http://git.iain.cx/?p=nssm.git;a=commitdiff_plain;h=565d5e4871c26bebf0417f290a21e449a6b049e0 Fixed argument parsing for setting ObjectName. Setting ObjectName needs a username and password, except when it doesn't. We can't make the extra argument mandatory because it isn't. --- diff --git a/service.cpp b/service.cpp index 5a732b0..91e726f 100644 --- a/service.cpp +++ b/service.cpp @@ -791,6 +791,10 @@ int pre_edit_service(int argc, TCHAR **argv) { additional = argv[3]; remainder = 4; } + else if (str_equiv(setting->name, NSSM_NATIVE_OBJECTNAME) && mode == MODE_SETTING) { + additional = argv[3]; + remainder = 4; + } else { additional = argv[remainder]; if (argc < mandatory) return usage(1); @@ -933,6 +937,9 @@ int pre_edit_service(int argc, TCHAR **argv) { /* Unset the parameter. */ value.string = 0; } + else if (remainder == argc) { + value.string = 0; + } else { /* Set the parameter. */ size_t len = 0; diff --git a/settings.cpp b/settings.cpp index 73b8d0d..e7ec830 100644 --- a/settings.cpp +++ b/settings.cpp @@ -838,7 +838,7 @@ settings_t settings[] = { { NSSM_NATIVE_DESCRIPTION, REG_SZ, _T(""), true, 0, native_set_description, native_get_description }, { NSSM_NATIVE_DISPLAYNAME, REG_SZ, NULL, true, 0, native_set_displayname, native_get_displayname }, { NSSM_NATIVE_IMAGEPATH, REG_EXPAND_SZ, NULL, true, 0, native_set_imagepath, native_get_imagepath }, - { NSSM_NATIVE_OBJECTNAME, REG_SZ, NSSM_LOCALSYSTEM_ACCOUNT, true, ADDITIONAL_SETTING, native_set_objectname, native_get_objectname }, + { NSSM_NATIVE_OBJECTNAME, REG_SZ, NSSM_LOCALSYSTEM_ACCOUNT, true, 0, native_set_objectname, native_get_objectname }, { NSSM_NATIVE_NAME, REG_SZ, NULL, true, 0, native_set_name, native_get_name }, { NSSM_NATIVE_STARTUP, REG_SZ, NULL, true, 0, native_set_startup, native_get_startup }, { NSSM_NATIVE_TYPE, REG_SZ, NULL, true, 0, native_set_type, native_get_type },