X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=nssm.cpp;h=3df55bcc523e00d84ba4f2d7351bd10ed38759d8;hb=caaaa1208f29647987173f7d9bc1aa75b58757b7;hp=0b586f36cb427fdacc1d1f6dd631c79cd082bbb4;hpb=fb96938cf944edf3bc0dfd99dbff416b0397df4f;p=nssm.git diff --git a/nssm.cpp b/nssm.cpp index 0b586f3..3df55bc 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -6,6 +6,7 @@ extern imports_t imports; static TCHAR unquoted_imagepath[PATH_LENGTH]; static TCHAR imagepath[PATH_LENGTH]; +static TCHAR imageargv0[PATH_LENGTH]; /* Are two strings case-insensitively equivalent? */ int str_equiv(const TCHAR *a, const TCHAR *b) { @@ -104,6 +105,10 @@ const TCHAR *nssm_imagepath() { return imagepath; } +const TCHAR *nssm_exe() { + return imageargv0; +} + int _tmain(int argc, TCHAR **argv) { check_console(); @@ -123,6 +128,8 @@ int _tmain(int argc, TCHAR **argv) { if (get_imports()) exit(111); /* Remember our path for later. */ + _sntprintf_s(imageargv0, _countof(imageargv0), _TRUNCATE, _T("%s"), argv[0]); + PathQuoteSpaces(imageargv0); GetModuleFileName(0, unquoted_imagepath, _countof(unquoted_imagepath)); GetModuleFileName(0, imagepath, _countof(imagepath)); PathQuoteSpaces(imagepath); @@ -146,6 +153,7 @@ int _tmain(int argc, TCHAR **argv) { if (str_equiv(argv[1], _T("rotate"))) exit(control_service(NSSM_SERVICE_CONTROL_ROTATE, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("install"))) { if (! is_admin) exit(elevate(argc, argv, NSSM_MESSAGE_NOT_ADMINISTRATOR_CANNOT_INSTALL)); + create_messages(); exit(pre_install_service(argc - 2, argv + 2)); } if (str_equiv(argv[1], _T("edit")) || str_equiv(argv[1], _T("get")) || str_equiv(argv[1], _T("set")) || str_equiv(argv[1], _T("reset")) || str_equiv(argv[1], _T("unset"))) { @@ -155,6 +163,7 @@ int _tmain(int argc, TCHAR **argv) { for (int i = 0; i < argc; i++) SecureZeroMemory(argv[i], _tcslen(argv[i]) * sizeof(TCHAR)); exit(ret); } + if (str_equiv(argv[1], _T("list"))) exit(list_nssm_services()); if (str_equiv(argv[1], _T("remove"))) { if (! is_admin) exit(elevate(argc, argv, NSSM_MESSAGE_NOT_ADMINISTRATOR_CANNOT_REMOVE)); exit(pre_remove_service(argc - 2, argv + 2));