return error_message;\r
}\r
\r
+/* Convert message code to format string */\r
+char *message_string(unsigned long error) {\r
+ char *ret;\r
+ if (! FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, 0, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR) &ret, NSSM_ERROR_BUFSIZE, 0)) {\r
+ ret = (char *) HeapAlloc(GetProcessHeap(), 0, 32);\r
+ if (_snprintf(ret, NSSM_ERROR_BUFSIZE, "system error %lu", error) < 0) return 0;\r
+ }\r
+ return ret;\r
+}\r
+\r
/* Log a message to the Event Log */\r
void log_event(unsigned short type, unsigned long id, ...) {\r
va_list arg;\r
/* Close event log */\r
DeregisterEventSource(handle);\r
}\r
+\r
+/* Log a message to the console */\r
+void print_message(FILE *file, unsigned long id, ...) {\r
+ va_list arg;\r
+\r
+ char *format = message_string(id);\r
+ if (! format) return;\r
+\r
+ va_start(arg, id);\r
+ vfprintf(file, format, arg);\r
+ va_end(arg);\r
+\r
+ LocalFree(format);\r
+}\r
+\r
+/* Show a GUI dialogue */\r
+int popup_message(unsigned int type, unsigned long id, ...) {\r
+ va_list arg;\r
+\r
+ char *format = message_string(id);\r
+ if (! format) {\r
+ return MessageBox(0, "Message %lu was supposed to go here!", NSSM, MB_OK | MB_ICONEXCLAMATION);\r
+ }\r
+\r
+ char blurb[256];\r
+ va_start(arg, id);\r
+ if (vsnprintf(blurb, sizeof(blurb), format, arg) < 0) {\r
+ va_end(arg);\r
+ LocalFree(format);\r
+ return MessageBox(0, "Message %lu was supposed to go here!", NSSM, MB_OK | MB_ICONEXCLAMATION);\r
+ }\r
+ va_end(arg);\r
+\r
+ int ret = MessageBox(0, blurb, NSSM, type);\r
+\r
+ LocalFree(format);\r
+\r
+ return ret;\r
+}\r
#define EVENT_H\r
\r
char *error_string(unsigned long);\r
+char *message_string(unsigned long);\r
void log_event(unsigned short, unsigned long, ...);\r
+void print_message(FILE *, unsigned long, ...);\r
+int popup_message(unsigned int, unsigned long, ...);\r
\r
#endif\r
#include "nssm.h"\r
\r
int nssm_gui(int resource, char *name) {\r
- char blurb[256];\r
-\r
/* Create window */\r
HWND dlg = CreateDialog(0, MAKEINTRESOURCE(resource), 0, install_dlg);\r
if (! dlg) {\r
- _snprintf(blurb, sizeof(blurb), "CreateDialog() failed with error code %d", GetLastError());\r
- MessageBox(0, blurb, NSSM, MB_OK);\r
+ popup_message(MB_OK, NSSM_GUI_CREATEDIALOG_FAILED, error_string(GetLastError()));\r
return 1;\r
}\r
\r
\r
/* Get service name */\r
if (! GetDlgItemText(window, IDC_NAME, name, sizeof(name))) {\r
- MessageBox(0, "No valid service name was specified!", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_SERVICE_NAME);\r
return 2;\r
}\r
\r
/* Get executable name */\r
if (! GetDlgItemText(window, IDC_PATH, exe, sizeof(exe))) {\r
- MessageBox(0, "No valid executable path was specified!", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PATH);\r
return 3;\r
}\r
\r
/* Get flags */\r
if (SendMessage(GetDlgItem(window, IDC_FLAGS), WM_GETTEXTLENGTH, 0, 0)) {\r
if (! GetDlgItemText(window, IDC_FLAGS, flags, sizeof(flags))) {\r
- MessageBox(0, "No valid options were specified!", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_OPTIONS);\r
return 4;\r
}\r
}\r
/* See if it works */\r
switch (install_service(name, exe, flags)) {\r
case 2:\r
- MessageBox(0, "Can't open service manager!\nPerhaps you need to be an administrator...", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED);\r
return 2;\r
\r
case 3:\r
- MessageBox(0, "Path too long!\nThe full path to " NSSM " is too long.\nPlease install " NSSM " somewhere else...\n", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_PATH_TOO_LONG, NSSM);\r
return 3;\r
\r
case 4:\r
- MessageBox(0, "Error constructing ImagePath!\nThis really shouldn't happen. You could be out of memory\nor the world may be about to end or something equally bad.", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_OUT_OF_MEMORY_FOR_IMAGEPATH);\r
return 4;\r
\r
case 5:\r
- MessageBox(0, "Couldn't create service!\nPerhaps it is already installed...", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INSTALL_SERVICE_FAILED);\r
return 5;\r
\r
case 6:\r
- MessageBox(0, "Couldn't set startup parameters for the service!\nDeleting the service...", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_CREATE_PARAMETERS_FAILED);\r
return 6;\r
}\r
\r
- MessageBox(0, "Service successfully installed!", NSSM, MB_OK);\r
+ popup_message(MB_OK, NSSM_MESSAGE_SERVICE_INSTALLED, name);\r
return 0;\r
}\r
\r
\r
/* Get service name */\r
if (! GetDlgItemText(window, IDC_NAME, name, sizeof(name))) {\r
- MessageBox(0, "No valid service name was specified!", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_SERVICE_NAME);\r
return 2;\r
}\r
\r
/* Confirm */\r
- char blurb[MAX_PATH];\r
- if (_snprintf(blurb, sizeof(blurb), "Remove the \"%s\" service?", name) < 0) {\r
- if (MessageBox(0, "Remove the service?", NSSM, MB_YESNO) != IDYES) return 0;\r
- }\r
- else if (MessageBox(0, blurb, NSSM, MB_YESNO) != IDYES) return 0;\r
+ if (popup_message(MB_YESNO, NSSM_GUI_ASK_REMOVE_SERVICE, name) != IDYES) return 0;\r
\r
/* See if it works */\r
switch (remove_service(name)) {\r
case 2:\r
- MessageBox(0, "Can't open service manager!\nPerhaps you need to be an administrator...", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED);\r
return 2;\r
\r
case 3:\r
- MessageBox(0, "Can't open service!\nPerhaps it isn't installed...", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_SERVICE_NOT_INSTALLED);\r
return 3;\r
\r
case 4:\r
- MessageBox(0, "Can't delete service! Make sure the service is stopped and try again.\nIf this error persists, you may need to set the service NOT to start\nautomatically, reboot your computer and try removing it again.", NSSM, MB_OK);\r
+ popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_REMOVE_SERVICE_FAILED);\r
return 4;\r
}\r
\r
- MessageBox(0, "Service successfully removed!", NSSM, MB_OK);\r
+ popup_message(MB_OK, NSSM_MESSAGE_SERVICE_REMOVED, name);\r
return 0;\r
}\r
\r
-/* Browse for game */\r
+/* Browse for application */\r
void browse(HWND window) {\r
if (! window) return;\r
\r
+ unsigned long bufsize = 256;\r
+ unsigned long len = bufsize;\r
OPENFILENAME ofn;\r
ZeroMemory(&ofn, sizeof(ofn));\r
ofn.lStructSize = sizeof(ofn);\r
- ofn.lpstrFilter = "Applications\0*.exe\0All files\0*.*\0\0";\r
+ ofn.lpstrFilter = (char *) HeapAlloc(GetProcessHeap(), 0, bufsize);\r
+ /* XXX: Escaping nulls with FormatMessage is tricky */\r
+ if (ofn.lpstrFilter) {\r
+ ZeroMemory((void *) ofn.lpstrFilter, bufsize);\r
+ char *localised = message_string(NSSM_GUI_BROWSE_FILTER_APPLICATIONS);\r
+ _snprintf((char *) ofn.lpstrFilter, bufsize, localised);\r
+ /* "Applications" + NULL + "*.exe" + NULL */\r
+ len = strlen(localised) + 1;\r
+ LocalFree(localised);\r
+ _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, "*.exe");\r
+ /* "All files" + NULL + "*.*" + NULL */\r
+ len += 6;\r
+ localised = message_string(NSSM_GUI_BROWSE_FILTER_ALL_FILES);\r
+ _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, localised);\r
+ len += strlen(localised) + 1;\r
+ LocalFree(localised);\r
+ _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, "*.*");\r
+ /* Remainder of the buffer is already zeroed */\r
+ }\r
ofn.lpstrFile = new char[MAX_PATH];\r
ofn.lpstrFile[0] = '\0';\r
- ofn.lpstrTitle = "Locate application file";\r
+ ofn.lpstrTitle = message_string(NSSM_GUI_BROWSE_TITLE);\r
ofn.nMaxFile = MAX_PATH;\r
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;\r
\r
if (GetOpenFileName(&ofn)) {\r
SendMessage(window, WM_SETTEXT, 0, (LPARAM) ofn.lpstrFile);\r
}\r
+ if (ofn.lpstrFilter) HeapFree(GetProcessHeap(), 0, (void *) ofn.lpstrFilter);\r
\r
delete[] ofn.lpstrFile;\r
}\r
French=0x40C:MSG0040C
)
+MessageId = 501
+SymbolicName = NSSM_MESSAGE_USAGE
+Severity = Informational
+Language = English
+NSSM: The non-sucking service manager
+Version %s, %s
+Usage: nssm <option> [args]
+
+To show service installation GUI:
+
+ nssm install [<servicename>]
+
+To install a service without confirmation:
+
+ nssm install <servicename> <app> [<args>]
+
+To show service removal GUI:
+
+ nssm remove [<servicename>]
+
+To remove a service without confirmation:
+
+ nssm remove <servicename> confirm
+.
+Language = French
+NSSM: Le gestionnaire de services Windows pour les professionnels!
+Version %s, %s
+Syntaxe: nssm <option> [arguments]
+
+Pour afficher l'écran d'installation du service:
+
+ nssm install [<nom_du_service>]
+
+Pour installer un service sans confirmation:
+
+ nssm install <nom_du_service> <application> [<arguments>]
+
+Pour afficher l'écran de désinstallation du service:
+
+ nssm remove [<nom_du_service>]
+
+Pour désinstaller un service sans confirmation:
+
+ nssm remove <nom_du_service> confirm
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_NOT_ADMINISTRATOR_CANNOT_INSTALL
+Severity = Informational
+Language = English
+Administrator access is needed to install a service.
+.
+Language = French
+Les droits d'administrateur sont requis pour installer un service.
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_NOT_ADMINISTRATOR_CANNOT_REMOVE
+Severity = Informational
+Language = English
+Administrator access is needed to remove a service.
+.
+Language = French
+Les droits d'administrateur sont requis pour désinstaller un service.
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_PRE_REMOVE_SERVICE
+Severity = Informational
+Language = English
+To remove a service without confirmation: nssm remove <servicename> confirm
+.
+Language = French
+Pour désinstaller un service sans confirmation: nssm remove <nom_du_service> confirm
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED
+Severity = Informational
+Language = English
+Error opening service manager!
+.
+Language = French
+Erreur à l'ouverture du gestionnaire de services!
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_PATH_TOO_LONG
+Severity = Informational
+Language = English
+The full path to %s is too long!
+.
+Language = French
+Le chemin complet vers %s est trop long!
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_OUT_OF_MEMORY_FOR_IMAGEPATH
+Severity = Informational
+Language = English
+Out of memory for ImagePath!
+.
+Language = French
+Mémoire insuffisante pour spécifier le chemin de l'image (ImagePath)!
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_CREATESERVICE_FAILED
+Severity = Informational
+Language = English
+Error creating service!
+.
+Language = French
+Erreur à la création du service!
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_CREATE_PARAMETERS_FAILED
+Severity = Informational
+Language = English
+Error setting startup parameters for the service!
+.
+Language = French
+Erreur en essayant de régler les paramètres de démarrage du service!
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_SERVICE_INSTALLED
+Severity = Informational
+Language = English
+Service "%s" installed successfully!
+.
+Language = French
+Le service "%s" a été installé avec succès!
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_OPENSERVICE_FAILED
+Severity = Informational
+Language = English
+Can't open service!
+.
+Language = French
+Impossible d'ouvrir le service!
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_DELETESERVICE_FAILED
+Severity = Informational
+Language = English
+Error deleting service!
+.
+Language = French
+Erreur à la suppression du service!
+.
+
+MessageId = +1
+SymbolicName = NSSM_MESSAGE_SERVICE_REMOVED
+Severity = Informational
+Language = English
+Service "%s" removed successfully!
+.
+Language = French
+Le service "%s" a été désinstallé avec succès!
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_CREATEDIALOG_FAILED
+Severity = Informational
+Language = English
+CreateDialog() failed:
+%s
+.
+Language = French
+CreateDialog() a échoué:
+%s
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_MISSING_SERVICE_NAME
+Severity = Informational
+Language = English
+No valid service name was specified!
+.
+Language = French
+Aucun nom de service valide n'a été spécifié!
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_MISSING_PATH
+Severity = Informational
+Language = English
+No valid executable path was specified!
+.
+Language = French
+Aucun chemin valide de fichier exécutable n'a été spécifié!
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_INVALID_OPTIONS
+Severity = Informational
+Language = English
+No valid options were specified!
+.
+Language = French
+Aucun option valide n'a été spécifiée!
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_OUT_OF_MEMORY_FOR_IMAGEPATH
+Severity = Informational
+Language = English
+Error constructing ImagePath!\nThis really shouldn't happen. You could be out of memory
+or the world may be about to end or something equally bad.
+.
+Language = French
+Mémoire insuffisante pour spécifier le chemin de l'image (ImagePath)!
+Cette situation ne devrait jamais se produire. Vous êtes peut-être à court de mémoire RAM,
+ou la fin du monde est proche, ou un autre désastre du même type.
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_INSTALL_SERVICE_FAILED
+Severity = Informational
+Language = English
+Couldn't create service!
+Perhaps it is already installed...
+.
+Language = French
+Impossible de créer le service!
+Peut-être est-il déjà installé...
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_CREATE_PARAMETERS_FAILED
+Severity = Informational
+Language = English
+Couldn't set startup parameters for the service!
+Deleting the service...
+.
+Language = French
+Impossible de régler les paramètres de démarrage pour le service!
+Suppression du dit service...
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_ASK_REMOVE_SERVICE
+Severity = Informational
+Language = English
+.
+Language = French
+Supprimer le service "%s" ?
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_SERVICE_NOT_INSTALLED
+Severity = Informational
+Language = English
+Can't open service!
+Perhaps it isn't installed...
+.
+Language = French
+Impossible d'ouvrir le service!
+Celui-ci n'est peut-être pas installé...
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_REMOVE_SERVICE_FAILED
+Severity = Informational
+Language = English
+Can't delete service! Make sure the service is stopped and try again.
+If this error persists, you may need to set the service NOT to start
+automatically, reboot your computer and try removing it again.
+.
+Language = French
+Impossible de supprimer le service! Assurez-vous que ce service est arrêté et réessayez.
+Si cette erreur persiste, réglez ce service en lancement MANUEL
+(non automatique), redémarrez votre ordinateur et tentez de nouveau la suppression.
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_BROWSE_FILTER
+Severity = Informational
+Language = English
+Applications%sAll files%s%0
+.
+Language = French
+Applications%sTous les fichiers%s%0
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_BROWSE_FILTER_APPLICATIONS
+Severity = Informational
+Language = English
+Applications%0
+.
+Language = French
+Applications%0
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_BROWSE_FILTER_ALL_FILES
+Severity = Informational
+Language = English
+All files%0
+.
+Language = French
+Tous les fichiers%0
+.
+
+MessageId = +1
+SymbolicName = NSSM_GUI_BROWSE_TITLE
+Severity = Informational
+Language = English
+Locate application file
+.
+Language = French
+Indiquez le fichier exécutable
+.
+
MessageId = 1001
SymbolicName = NSSM_EVENT_DISPATCHER_FAILED
Severity = Error
\r
/* How to use me correctly */\r
int usage(int ret) {\r
- fprintf(stderr, "NSSM: The non-sucking service manager\n");\r
- fprintf(stderr, "Version %s, %s\n", NSSM_VERSION, NSSM_DATE);\r
- fprintf(stderr, "Usage: nssm <option> [args]\n\n");\r
- fprintf(stderr, "To show service installation GUI:\n\n");\r
- fprintf(stderr, " nssm install [<servicename>]\n\n");\r
- fprintf(stderr, "To install a service without confirmation:\n\n");\r
- fprintf(stderr, " nssm install <servicename> <app> [<args>]\n\n");\r
- fprintf(stderr, "To show service removal GUI:\n\n");\r
- fprintf(stderr, " nssm remove [<servicename>]\n\n");\r
- fprintf(stderr, "To remove a service without confirmation:\n\n");\r
- fprintf(stderr, " nssm remove <servicename> confirm\n");\r
+ print_message(stderr, NSSM_MESSAGE_USAGE, NSSM_VERSION, NSSM_DATE);\r
return(ret);\r
}\r
\r
\r
/* Elevate */\r
if (argc > 1) {\r
- if (str_equiv(argv[1], "install") || str_equiv(argv[1], "remove")) {\r
+ /* Valid commands are install or remove */\r
+ if (str_equiv(argv[1], "install")) {\r
if (! is_admin) {\r
- fprintf(stderr, "Administrator access is needed to %s a service.\n", argv[1]);\r
+ print_message(stderr, NSSM_MESSAGE_NOT_ADMINISTRATOR_CANNOT_INSTALL);\r
exit(100);\r
}\r
- }\r
-\r
- /* Valid commands are install or remove */\r
- if (str_equiv(argv[1], "install")) {\r
exit(pre_install_service(argc - 2, argv + 2));\r
}\r
if (str_equiv(argv[1], "remove")) {\r
+ if (! is_admin) {\r
+ print_message(stderr, NSSM_MESSAGE_NOT_ADMINISTRATOR_CANNOT_REMOVE);\r
+ exit(100);\r
+ }\r
exit(pre_remove_service(argc - 2, argv + 2));\r
}\r
}\r
\r
/* About to install the service */\r
int pre_install_service(int argc, char **argv) {\r
- /* Show the dialogue box if we didn't give the */\r
+ /* Show the dialogue box if we didn't give the service name and path */\r
if (argc < 2) return nssm_gui(IDD_INSTALL, argv[0]);\r
\r
/* Arguments are optional */\r
/* Show dialogue box if we didn't pass service name and "confirm" */\r
if (argc < 2) return nssm_gui(IDD_REMOVE, argv[0]);\r
if (str_equiv(argv[1], "confirm")) return remove_service(argv[0]);\r
- fprintf(stderr, "To remove a service without confirmation: nssm remove <servicename> confirm\n");\r
+ print_message(stderr, NSSM_MESSAGE_PRE_REMOVE_SERVICE);\r
return 100;\r
}\r
\r
/* Open service manager */\r
SC_HANDLE services = open_service_manager();\r
if (! services) {\r
- fprintf(stderr, "Error opening service manager!\n");\r
+ print_message(stderr, NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED);\r
return 2;\r
}\r
\r
char command[CMD_LENGTH];\r
size_t pathlen = strlen(path);\r
if (pathlen + 1 >= VALUE_LENGTH) {\r
- fprintf(stderr, "The full path to " NSSM " is too long!\n");\r
+ print_message(stderr, NSSM_MESSAGE_PATH_TOO_LONG, NSSM);\r
return 3;\r
}\r
if (_snprintf(command, sizeof(command), "\"%s\"", path) < 0) {\r
- fprintf(stderr, "Out of memory for ImagePath!\n");\r
+ print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY_FOR_IMAGEPATH);\r
return 4;\r
}\r
\r
/* Create the service */\r
SC_HANDLE service = CreateService(services, name, name, SC_MANAGER_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, command, 0, 0, 0, 0, 0);\r
if (! service) {\r
- fprintf(stderr, "Error creating service!\n");\r
+ print_message(stderr, NSSM_MESSAGE_CREATESERVICE_FAILED);\r
CloseServiceHandle(services);\r
return 5;\r
}\r
\r
/* Now we need to put the parameters into the registry */\r
if (create_parameters(name, exe, flags, dir)) {\r
- fprintf(stderr, "Error setting startup parameters for the service!\n");\r
+ print_message(stderr, NSSM_MESSAGE_CREATE_PARAMETERS_FAILED);\r
DeleteService(service);\r
CloseServiceHandle(services);\r
return 6;\r
CloseServiceHandle(service);\r
CloseServiceHandle(services);\r
\r
- printf("Service \"%s\" installed successfully!\n", name);\r
+ print_message(stdout, NSSM_MESSAGE_SERVICE_INSTALLED, name);\r
return 0;\r
}\r
\r
/* Open service manager */\r
SC_HANDLE services = open_service_manager();\r
if (! services) {\r
- fprintf(stderr, "Error opening service manager!\n");\r
+ print_message(stderr, NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED);\r
return 2;\r
}\r
\r
/* Try to open the service */\r
SC_HANDLE service = OpenService(services, name, SC_MANAGER_ALL_ACCESS);\r
if (! service) {\r
- fprintf(stderr, "Can't open service!");\r
+ print_message(stderr, NSSM_MESSAGE_OPENSERVICE_FAILED);\r
CloseServiceHandle(services);\r
return 3;\r
}\r
\r
/* Try to delete the service */\r
if (! DeleteService(service)) {\r
- fprintf(stderr, "Error deleting service!\n");\r
+ print_message(stderr, NSSM_MESSAGE_DELETESERVICE_FAILED);\r
CloseServiceHandle(service);\r
CloseServiceHandle(services);\r
return 4;\r
CloseServiceHandle(service);\r
CloseServiceHandle(services);\r
\r
- printf("Service \"%s\" removed successfully!\n", name);\r
+ print_message(stdout, NSSM_MESSAGE_SERVICE_REMOVED, name);\r
return 0;\r
}\r
\r