Browse Source

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.
Iain Patterson 8 years ago
parent
commit
565d5e4871
2 changed files with 8 additions and 1 deletions
  1. 7 0
      service.cpp
  2. 1 1
      settings.cpp

+ 7 - 0
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;

+ 1 - 1
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 },