public async Task <Process> Run() { string exePath = Path.Combine(MainWindow.WGSM_PATH, @"installer\steamcmd\steamcmd.exe"); if (!File.Exists(exePath)) { Error = $"steamcmd.exe not found ({exePath})"; return(null); } WindowsFirewall firewall = new WindowsFirewall("steamcmd.exe", exePath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process(); p.StartInfo.FileName = exePath; p.StartInfo.Arguments = _param; p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); return(p); }
public async Task <Process> Start(string param) { string workingDir = Functions.Path.GetServerFiles(_serverId); string hldsPath = Path.Combine(workingDir, "hlds.exe"); if (!File.Exists(hldsPath)) { Error = $"hlds.exe not found ({hldsPath})"; return(null); } if (string.IsNullOrWhiteSpace(param)) { Error = "Start Parameter not set"; return(null); } WindowsFirewall firewall = new WindowsFirewall("hlds.exe", hldsPath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process(); p.StartInfo.WorkingDirectory = workingDir; p.StartInfo.FileName = hldsPath; p.StartInfo.Arguments = param; p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); return(p); }
public Process Run() { string exePath = MainWindow.WGSM_PATH + @"\installer\steamcmd\steamcmd.exe"; if (!File.Exists(exePath)) { Error = "steamcmd.exe not found (" + exePath + ")"; return(null); } WindowsFirewall firewall = new WindowsFirewall("steamcmd.exe", exePath); if (!firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process(); p.StartInfo.FileName = exePath; p.StartInfo.Arguments = Param; p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); return(p); }
public async Task <Process> Run() { string exeFile = "steamcmd.exe"; string exePath = Path.Combine(_installPath, exeFile); if (!File.Exists(exePath)) { //If steamcmd.exe not exists, download steamcmd.exe if (!await Download()) { Error = $"Fail to download {exeFile}"; return(null); } } if (_param == null) { Error = "Steam account is not set"; return(null); } Console.WriteLine($"SteamCMD Param: {_param}"); WindowsFirewall firewall = new WindowsFirewall(exeFile, exePath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process { StartInfo = { WorkingDirectory = _installPath, FileName = exePath, Arguments = _param, WindowStyle = ProcessWindowStyle.Minimized, CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, StandardOutputEncoding = System.Text.Encoding.UTF8, RedirectStandardOutput = true, RedirectStandardError = true }, EnableRaisingEvents = true }; p.Start(); return(p); }
public async Task <Process> Start() { string fxServerPath = Functions.Path.GetServerFiles(_serverId, @"server\FXServer.exe"); if (!File.Exists(fxServerPath)) { Error = $"FXServer.exe not found ({fxServerPath})"; return(null); } string citizenPath = Functions.Path.GetServerFiles(_serverId, @"server\citizen"); if (!Directory.Exists(citizenPath)) { Error = $"Directory citizen not found ({citizenPath})"; return(null); } string serverDataPath = Functions.Path.GetServerFiles(_serverId, "cfx-server-data-master"); if (!Directory.Exists(serverDataPath)) { Error = $"Directory cfx-server-data-master not found ({serverDataPath})"; return(null); } string configPath = Path.Combine(serverDataPath, "server.cfg"); if (!File.Exists(configPath)) { Notice = $"server.cfg not found ({configPath})"; } WindowsFirewall firewall = new WindowsFirewall("FXServer.exe", fxServerPath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process(); p.StartInfo.WorkingDirectory = serverDataPath; p.StartInfo.FileName = fxServerPath; p.StartInfo.Arguments = $"+set citizen_dir \"{citizenPath}\" {_param}"; p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); return(p); }
public async Task <string> GetRemoteBuild(string appId) { string exePath = Path.Combine(_installPath, "steamcmd.exe"); if (!File.Exists(exePath)) { //If steamcmd.exe not exists, download steamcmd.exe if (!await Download()) { Error = "Fail to download steamcmd.exe"; return(""); } } WindowsFirewall firewall = new WindowsFirewall("steamcmd.exe", exePath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process { StartInfo = { FileName = exePath, //Sometimes it fails to get if appID < 90 Arguments = $"+login anonymous +app_info_update 1 +app_info_print {appId} +app_info_print {appId} +app_info_print {appId} +app_info_print {appId} +quit", WindowStyle = ProcessWindowStyle.Minimized, CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true } }; p.Start(); string output = await p.StandardOutput.ReadToEndAsync(); Regex regex = new Regex("\"public\"\r\n.{0,}{\r\n.{0,}\"buildid\".{1,}\"(.*?)\""); var matches = regex.Matches(output); if (matches.Count < 1 || matches[1].Groups.Count < 2) { Error = $"Fail to get remote build"; return(""); } return(matches[0].Groups[1].Value); }
public async Task <Process> Start() { int isJavaInstalled = IsJavaJREInstalled(); if (isJavaInstalled == 0) { Error = "Java is not installed"; return(null); } string workingDir = Functions.Path.GetServerFiles(_serverId); string serverJarPath = Path.Combine(workingDir, "server.jar"); if (!File.Exists(serverJarPath)) { Error = $"server.jar not found ({serverJarPath})"; return(null); } string configPath = Path.Combine(workingDir, "server.properties"); if (!File.Exists(configPath)) { Notice = $"server.properties not found ({configPath}). Generated a new one."; } string javaPath = (isJavaInstalled == 1) ? "java" : "C:\\Program Files (x86)\\Java\\jre1.8.0_231\\bin\\java.exe"; if (isJavaInstalled == 2) { WindowsFirewall firewall = new WindowsFirewall("java.exe", javaPath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } } Process p = new Process(); p.StartInfo.WorkingDirectory = workingDir; p.StartInfo.FileName = javaPath; p.StartInfo.Arguments = $"{_param} -jar server.jar nogui"; p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); return(p); }
public async Task <Process> Start() { string workingDir = Functions.Path.GetServerFiles(_serverId); string phpPath = workingDir + @"\bin\php\php.exe"; if (!File.Exists(phpPath)) { Error = $"php.exe not found ({phpPath})"; return(null); } string PMMPPath = workingDir + @"\PocketMine-MP.phar"; if (!File.Exists(PMMPPath)) { Error = $"PocketMine-MP.phar not found ({PMMPPath})"; return(null); } string serverConfigPath = workingDir + @"\server.properties"; if (!File.Exists(serverConfigPath)) { Error = $"server.properties not found ({serverConfigPath})"; return(null); } WindowsFirewall firewall = new WindowsFirewall("php.exe", phpPath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process(); p.StartInfo.WorkingDirectory = workingDir; p.StartInfo.FileName = phpPath; p.StartInfo.Arguments = @"-c bin\php PocketMine-MP.phar"; p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); return(p); }
public (Process Process, string Error, string Notice) Start() { string workingDir = Functions.Path.GetServerFiles(ServerID); string phpPath = workingDir + @"\bin\php\php.exe"; if (!File.Exists(phpPath)) { return(null, "php.exe not found (" + phpPath + ")", ""); } string PMMPPath = workingDir + @"\PocketMine-MP.phar"; if (!File.Exists(PMMPPath)) { return(null, "PocketMine-MP.phar not found (" + PMMPPath + ")", ""); } string serverConfigPath = workingDir + @"\server.properties"; if (!File.Exists(serverConfigPath)) { return(null, "server.properties not found (" + serverConfigPath + ")", ""); } WindowsFirewall firewall = new WindowsFirewall("php.exe", phpPath); if (!firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process(); p.StartInfo.WorkingDirectory = workingDir; p.StartInfo.FileName = phpPath; p.StartInfo.Arguments = @"-c bin\php PocketMine-MP.phar"; p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); return(p, "", ""); }
public (Process Process, string Error, string Notice) Start() { string workingDir = Functions.Path.GetServerFiles(ServerID); string hldsPath = workingDir + @"\hlds.exe"; if (!File.Exists(hldsPath)) { return(null, "hlds.exe not found (" + hldsPath + ")", ""); } if (string.IsNullOrWhiteSpace(Param)) { return(null, "Start Parameter not set", ""); } string serverConfigPath = workingDir + @"\czero\server.cfg"; if (!File.Exists(serverConfigPath)) { return(null, "", "server.cfg not found (" + serverConfigPath + ")"); } WindowsFirewall firewall = new WindowsFirewall("hlds.exe", hldsPath); if (!firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process(); p.StartInfo.WorkingDirectory = workingDir; p.StartInfo.FileName = hldsPath; p.StartInfo.Arguments = Param; p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); return(p, "", ""); }
public async Task <Process> Start(string param, string customSrcdsName = "srcds.exe", bool setWorkingDirectory = true) { string workingDir = Functions.Path.GetServerFiles(_serverId); string srcdsPath = Path.Combine(workingDir, customSrcdsName); if (!File.Exists(srcdsPath)) { Error = $"{customSrcdsName} not found ({srcdsPath})"; return(null); } if (string.IsNullOrWhiteSpace(param)) { Error = "Start Parameter not set"; return(null); } WindowsFirewall firewall = new WindowsFirewall(customSrcdsName, srcdsPath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p = new Process(); if (setWorkingDirectory) { p.StartInfo.WorkingDirectory = workingDir; } p.StartInfo.FileName = srcdsPath; p.StartInfo.Arguments = param; p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p.Start(); return(p); }
public async Task <Process> Start() { string exeName = "7DaysToDieServer.exe"; string workingDir = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID); string exePath = Path.Combine(workingDir, exeName); if (!File.Exists(exePath)) { Error = $"{exeName} not found ({exePath})"; return(null); } string configPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, "serverconfig.xml"); if (!File.Exists(configPath)) { Notice = $"serverconfig.xml not found ({configPath})"; } string logFile = @"7DaysToDieServer_Data\output_log_dedi__" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".txt"; string param = $"-logfile \"{Path.Combine(workingDir, logFile)}\" -quit -batchmode -nographics -configfile=serverconfig.xml -dedicated {_serverData.ServerParam}"; WindowsFirewall firewall = new WindowsFirewall(exeName, exePath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p; if (!AllowsEmbedConsole) { p = new Process { StartInfo = { WorkingDirectory = workingDir, FileName = exePath, Arguments = param, WindowStyle = ProcessWindowStyle.Minimized }, EnableRaisingEvents = true }; p.Start(); } else { p = new Process { StartInfo = { WorkingDirectory = workingDir, FileName = exePath, Arguments = param, WindowStyle = ProcessWindowStyle.Minimized, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true }, EnableRaisingEvents = true }; var serverConsole = new Functions.ServerConsole(_serverData.ServerID); p.OutputDataReceived += serverConsole.AddOutput; p.ErrorDataReceived += serverConsole.AddOutput; p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); } return(p); }
public async Task <Process> Start() { // Use DZSALModServer.exe if the exe exist, otherwise use original string dzsaPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, "DZSALModServer.exe"); if (File.Exists(dzsaPath)) { StartPath = "DZSALModServer.exe"; WindowsFirewall firewall = new WindowsFirewall(StartPath, dzsaPath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } } else { string serverPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath); if (!File.Exists(serverPath)) { Error = $"{StartPath} not found ({serverPath})"; return(null); } } string configPath = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, "serverDZ.cfg"); if (!File.Exists(configPath)) { Notice = $"{Path.GetFileName(configPath)} not found ({configPath})"; } string param = $" {_serverData.ServerParam}"; param += string.IsNullOrEmpty(_serverData.ServerIP) ? string.Empty : $" -ip={_serverData.ServerIP}"; param += string.IsNullOrEmpty(_serverData.ServerPort) ? string.Empty : $" -port={_serverData.ServerPort}"; string modPath = Functions.ServerPath.GetServersConfigs(_serverData.ServerID, "DayZActivatedMods.cfg"); if (File.Exists(modPath)) { string modParam = string.Empty; foreach (string modName in File.ReadLines(modPath)) { modParam += $"{modName.Trim()};"; } if (!string.IsNullOrWhiteSpace(modParam)) { param += $" \"-mod={modParam}\""; } } Process p = new Process { StartInfo = { WorkingDirectory = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID), FileName = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath), Arguments = param, WindowStyle = ProcessWindowStyle.Minimized, UseShellExecute = false }, EnableRaisingEvents = true }; p.Start(); return(p); }
public async Task <Process> Start() { string javaPath = JavaHelper.FindJavaExecutableAbsolutePath(); if (javaPath.Length == 0) { Error = "Java is not installed"; return(null); } string workingDir = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID); string serverJarPath = Path.Combine(workingDir, "server.jar"); if (!File.Exists(serverJarPath)) { Error = $"server.jar not found ({serverJarPath})"; return(null); } string configPath = Path.Combine(workingDir, "server.properties"); if (!File.Exists(configPath)) { Notice = $"server.properties not found ({configPath}). Generated a new one."; } WindowsFirewall firewall = new WindowsFirewall("java.exe", javaPath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } Process p; if (!AllowsEmbedConsole) { p = new Process { StartInfo = { WorkingDirectory = workingDir, FileName = javaPath, Arguments = $"{_serverData.ServerParam} -jar server.jar nogui", WindowStyle = ProcessWindowStyle.Minimized, UseShellExecute = false }, EnableRaisingEvents = true }; p.Start(); } else { p = new Process { StartInfo = { WorkingDirectory = workingDir, FileName = javaPath, Arguments = $"{_serverData.ServerParam} -jar server.jar nogui", WindowStyle = ProcessWindowStyle.Minimized, CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }, EnableRaisingEvents = true }; var serverConsole = new Functions.ServerConsole(_serverData.ServerID); p.OutputDataReceived += serverConsole.AddOutput; p.ErrorDataReceived += serverConsole.AddOutput; p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); } return(p); }
public async Task <Process> Start() { string exeFile = "MordhauServer.exe"; string exePath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, exeFile); if (!File.Exists(exePath)) { Error = $"{exeFile} not found ({exePath})"; return(null); } string shipExeFile = "MordhauServer-Win64-Shipping.exe"; string shipExePath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, @"Mordhau\Binaries\Win64", shipExeFile); WindowsFirewall firewall = new WindowsFirewall(shipExeFile, shipExePath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } if (!File.Exists(shipExePath)) { Error = $"{shipExeFile} not found ({shipExePath})"; return(null); } string configFile = "Game.ini"; string configPath = Functions.ServerPath.GetServerFiles(_serverData.ServerID, @"Mordhau\Saved\Config\WindowsServer", configFile); if (!File.Exists(configPath)) { Notice = $"{configFile} not found ({configPath})"; } string param = string.IsNullOrWhiteSpace(_serverData.ServerMap) ? "" : $"{_serverData.ServerMap}"; param += string.IsNullOrWhiteSpace(_serverData.ServerIP) ? "" : $" -MultiHome={_serverData.ServerIP}"; param += string.IsNullOrWhiteSpace(_serverData.ServerPort) ? "" : $" -Port={_serverData.ServerPort}"; param += $" {_serverData.ServerParam}" + ((ToggleConsole) ? " -log" : ""); Process p; if (ToggleConsole) { p = new Process { StartInfo = { FileName = shipExePath, Arguments = param, WindowStyle = ProcessWindowStyle.Minimized, }, EnableRaisingEvents = true }; p.Start(); } else { p = new Process { StartInfo = { FileName = shipExePath, Arguments = param, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true }, EnableRaisingEvents = true }; var serverConsole = new Functions.ServerConsole(_serverData.ServerID); p.OutputDataReceived += serverConsole.AddOutput; p.ErrorDataReceived += serverConsole.AddOutput; p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); } return(p); }
public async Task <string> GetRemoteBuild(string appId) { string exePath = Path.Combine(_installPath, "steamcmd.exe"); if (!File.Exists(exePath)) { //If steamcmd.exe not exists, download steamcmd.exe if (!await Download()) { Error = "Fail to download steamcmd.exe"; return(string.Empty); } } WindowsFirewall firewall = new WindowsFirewall("steamcmd.exe", exePath); if (!await firewall.IsRuleExist()) { await firewall.AddRule(); } // Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD. await Task.Run(() => { string vdfPath = Path.Combine(_installPath, "appcache", "appinfo.vdf"); try { if (File.Exists(vdfPath)) { File.Delete(vdfPath); Debug.WriteLine($"Deleted appinfo.vdf ({vdfPath})"); } } catch { Debug.WriteLine($"File to delete appinfo.vdf ({vdfPath})"); } }); Process p = new Process { StartInfo = { FileName = exePath, //Sometimes it fails to get if appID < 90 Arguments = $"+login anonymous +app_info_update 1 +app_info_print {appId} +app_info_print {appId} +app_info_print {appId} +app_info_print {appId} +quit", WindowStyle = ProcessWindowStyle.Minimized, CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true } }; p.Start(); SendEnterPreventFreeze(p); string output = await p.StandardOutput.ReadToEndAsync(); Regex regex = new Regex("\"public\"\r\n.{0,}{\r\n.{0,}\"buildid\".{1,}\"(.*?)\""); var matches = regex.Matches(output); if (matches.Count < 1 || matches[1].Groups.Count < 2) { Error = $"Fail to get remote build"; return(string.Empty); } return(matches[0].Groups[1].Value); }
public async Task <Process> Start() { Java isJavaInstalled = IsJavaJREInstalled(); if (isJavaInstalled == Java.NotInstall) { Error = "Java is not installed"; return(null); } string workingDir = Functions.ServerPath.GetServersServerFiles(_serverData.ServerID); string serverJarPath = Path.Combine(workingDir, "server.jar"); if (!File.Exists(serverJarPath)) { Error = $"server.jar not found ({serverJarPath})"; return(null); } string configPath = Path.Combine(workingDir, "server.properties"); if (!File.Exists(configPath)) { Notice = $"server.properties not found ({configPath}). Generated a new one."; } string javaPath = (isJavaInstalled == Java.InstalledGlobal) ? "java" : "C:\\Program Files (x86)\\Java\\jre1.8.0_231\\bin\\java.exe"; if (isJavaInstalled == Java.InstalledAbsolute) { WindowsFirewall firewall = new WindowsFirewall("java.exe", javaPath); if (!await firewall.IsRuleExist()) { firewall.AddRule(); } } Process p; if (ToggleConsole) { p = new Process { StartInfo = { WorkingDirectory = workingDir, FileName = javaPath, Arguments = $"{_serverData.ServerParam} -jar server.jar nogui", WindowStyle = ProcessWindowStyle.Minimized, }, EnableRaisingEvents = true }; p.Start(); } else { p = new Process { StartInfo = { WorkingDirectory = workingDir, FileName = javaPath, Arguments = $"{_serverData.ServerParam} -jar server.jar nogui", WindowStyle = ProcessWindowStyle.Minimized, CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }, EnableRaisingEvents = true }; var serverConsole = new Functions.ServerConsole(_serverData.ServerID); p.OutputDataReceived += serverConsole.AddOutput; p.ErrorDataReceived += serverConsole.AddOutput; p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); } return(p); }