Coding Global Background
Coding Global

I need help!

Archived 2 years ago
4 messages
0 members
2 years ago
Open in Discord
Z
zichtig

How can i start a Minecraft Server with C#? This DOESNT work: ```using System; using System.Diagnostics; using System.IO; using System.Threading; class Program { static Process ServerProc; static void Main() { string ServerFile = "spigot-1.12.2.jar"; string ServerPath = @"C:\Users\brotc\Downloads\Server"; var startInfo = new ProcessStartInfo("java", "-Xmx1024M -Xms1024M -jar \"" + Path.Combine(ServerPath, ServerFile) + "\" nogui") { WorkingDirectory = ServerPath, RedirectStandardInput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }; ServerProc = new Process { StartInfo = startInfo, EnableRaisingEvents = true }; Console.WriteLine("Minecraft Server Console App"); StartServer(); Console.ReadKey(); } private static void StartServer() { try { ServerProc.Start(); ServerProc.BeginErrorReadLine(); Console.WriteLine("Server started."); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine($"Error starting the server: {ex.Message}"); Console.ReadKey(); } } }```

Replies (4)