//Удалется сам сервис, файлы логов, настройки и jar файлы public static void DeleteService(string settingsPath) { Service service = LoadSettings(settingsPath); string command = "cd JavaServices\\procrun & prunsrv delete " + service.serviceID; CmdCommand.ExecuteCommandSync(command); File.Delete(service.stdOutput); File.Delete(service.stdError); File.Delete(service.latestVersionPath); File.Delete(service.classpath); File.Delete(service.settingsPath); Console.WriteLine("Deleted"); }
//Установка сервиса public void InstallService() { string[] settings = new string[20]; string allsettings = ""; //Здесь собираются настройки для сервиса, которые выполнятся в cmd #region Settings settings[0] = install + " //IS//" + serviceID; settings[1] = "--DisplayName \"" + displayName + "\""; settings[2] = "--Description \"" + description + "\""; settings[3] = "--Startup=" + startup; settings[4] = "--Install=" + install; settings[5] = "--Jvm=" + jvm; settings[6] = "--Classpath \"" + classpath + "\""; settings[7] = "--Environment=" + environment; settings[8] = "--JavaHome=" + javaHome; settings[9] = "--StartPath=" + serviceDirectory; settings[10] = "--JvmOptions=" + jvmOptions; settings[11] = "--StartMode=" + startMode; settings[12] = "--StartClass=" + startClass; settings[13] = "--StartParams=" + startParams; settings[14] = "--StopMode=" + stopMode; settings[15] = "--StopClass=" + stopClass; settings[16] = "--StopParams=" + stopParams; settings[17] = "--StdOutput=" + stdOutput; settings[18] = "--StdError=" + stdError; #endregion for (int i = 0; i < 20; i++) { Console.WriteLine(settings[i]); } for (int i = 1; i < 20; i++) { allsettings += settings[i] + " "; } // jar сервис сохраняется в главную папку File.Copy(pathFile, classpath, true); File.Copy(pathFile, latestVersionPath, true); allsettings = "cd JavaServices\\procrun & prunsrv update " + serviceID + " " + allsettings; CmdCommand.ExecuteCommandSync(settings[0]); CmdCommand.ExecuteCommandSync(allsettings); }