+ case UI_MENU_MANAGE_STOP:
+
+ /* Stop OSSEC */
+ ret_code = os_stop_service();
+ if (ret_code == 1) {
+ config_read(hwnd);
+ gen_server_info(hwnd);
+
+ SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Stopped");
+ MessageBox(hwnd, "Agent stopped",
+ "Agent Stopped", MB_OK);
+ } else {
+ MessageBox(hwnd, "Agent already stopped",
+ "Agent Stopped", MB_OK);
+ }
+ break;
+ case UI_MENU_MANAGE_STATUS:
+ if (CheckServiceRunning()) {
+ MessageBox(hwnd, "Agent running",
+ "Agent Running", MB_OK);
+
+ } else {
+ MessageBox(hwnd, "Agent stopped",
+ "Agent Stopped", MB_OK);
+ }
+ break;
+ case UI_MENU_MANAGE_RESTART:
+
+ if ((strcmp(config_inst.key, FL_NOKEY) == 0) ||
+ (strcmp(config_inst.server, FL_NOSERVER) == 0)) {
+ MessageBox(hwnd, "Unable to restart agent (check config)",
+ "Error -- Unable to Restart Agent", MB_OK);
+ break;
+
+ }
+
+ ret_code = os_stop_service();
+
+ /* Start OSSEC */
+ ret_code = os_start_service();
+ if (ret_code == 0) {
+ MessageBox(hwnd, "Unable to restart agent (check config)",
+ "Error -- Unable to Restart Agent", MB_OK);
+ } else {
+ config_read(hwnd);
+ gen_server_info(hwnd);
+
+ SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Restarted");
+ MessageBox(hwnd, "Agent restarted",
+ "Agent Restarted", MB_OK);
+ }
+ break;
+ }
+ break;