Skip to content

Commit

Permalink
Allow querying a service's name.
Browse files Browse the repository at this point in the history
Since we can now open a service by its display name it may be
interesting to know what its canonical name is.

Find out with:

    nssm get <displayname> Name
  • Loading branch information
Iain Patterson committed Jan 1, 2014
1 parent 048ecc8 commit 121d394
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ run NSSM itself. The parameters recognised are as follows:
DisplayName: Service display name.
ImagePath: Path to the service executable.
ObjectName: User account which runs the service.
Name: Service key name.
Start: Service startup type.
Type: Service type.

Expand Down Expand Up @@ -381,6 +382,12 @@ exit code of 2, run
nssm set <servicename> AppExit 2 Exit


The Name parameter can only be queried, not set. It returns the service's
registry key name. This may be useful to know if you take advantage of
the fact that you can substitute the service's display name anywhere where
the syntax calls for <servicename>.


The ObjectName parameter requires an additional argument only when setting
a username. The additional argument is the password of the user.

Expand Down Expand Up @@ -486,6 +493,10 @@ To remove the server:

nssm remove UT2004 confirm

To find out the service name of a service with a display name:

nssm get "Background Intelligent Transfer Service" Name


Building NSSM from source
-------------------------
Expand Down
Binary file modified messages.mc
Binary file not shown.
10 changes: 10 additions & 0 deletions settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,15 @@ int native_get_imagepath(const TCHAR *service_name, void *param, const TCHAR *na
return ret;
}

int native_set_name(const TCHAR *service_name, void *param, const TCHAR *name, void *default_value, value_t *value, const TCHAR *additional) {
print_message(stderr, NSSM_MESSAGE_CANNOT_RENAME_SERVICE);
return -1;
}

int native_get_name(const TCHAR *service_name, void *param, const TCHAR *name, void *default_value, value_t *value, const TCHAR *additional) {
return value_from_string(name, value, service_name);
}

int native_set_objectname(const TCHAR *service_name, void *param, const TCHAR *name, void *default_value, value_t *value, const TCHAR *additional) {
SC_HANDLE service_handle = (SC_HANDLE) param;
if (! service_handle) return -1;
Expand Down Expand Up @@ -666,6 +675,7 @@ settings_t settings[] = {
{ 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_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 },
{ NULL, NULL, NULL, NULL, NULL }
Expand Down
1 change: 1 addition & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define NSSM_NATIVE_DESCRIPTION _T("Description")
#define NSSM_NATIVE_DISPLAYNAME _T("DisplayName")
#define NSSM_NATIVE_IMAGEPATH _T("ImagePath")
#define NSSM_NATIVE_NAME _T("Name")
#define NSSM_NATIVE_OBJECTNAME _T("ObjectName")
#define NSSM_NATIVE_STARTUP _T("Start")
#define NSSM_NATIVE_TYPE _T("Type")
Expand Down

0 comments on commit 121d394

Please sign in to comment.