Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2011
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public static void LaunchMinecraft(String file, String memoryValue)
  2. {
  3. String memParams = "-Xmx" + memoryValue + "M" + " -Xms" + memoryValue + "M ";
  4. String args = memParams + "-jar " + file + " nogui";
  5. ProcessStartInfo processInfo = new ProcessStartInfo("java.exe", args);
  6. processInfo.CreateNoWindow = true;
  7. processInfo.UseShellExecute = false;
  8. processInfo.RedirectStandardOutput = true;
  9. processInfo.RedirectStandardInput = true;
  10.  
  11. StreamWriter inputWriter = process.StandardInput;
  12. StreamReader outputReader = process.StandardOutput;
  13.  
  14. inputWriter.WriteLine("/save-all");
  15.  
  16. try
  17. {
  18. using (Process minecraftProcess = Process.Start(processInfo))
  19. {
  20. GlobalClass.ProcessID = minecraftProcess.Id;
  21. Console.WriteLine("Minecraft Process Started.");
  22. Console.WriteLine("Process ID is " + GlobalClass.ProcessID);
  23. minecraftProcess.WaitForExit();
  24. }
  25. }
  26. catch
  27. {
  28. // Log Error
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement