Created
December 16, 2019 00:33
-
-
Save francisrohner/ea28a41f9b1c9cad8119c90830cccaea to your computer and use it in GitHub Desktop.
Fix process priority for Modern Warfare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Security.Principal; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
namespace ProcPriorityModifier | |
{ | |
public class Program | |
{ | |
public static bool IsAdministrator() | |
{ | |
var identity = WindowsIdentity.GetCurrent(); | |
var principal = new WindowsPrincipal(identity); | |
return principal.IsInRole(WindowsBuiltInRole.Administrator); | |
} | |
[STAThread] | |
public static void Main(string[] args) | |
{ | |
if(!IsAdministrator()) | |
{ | |
Console.ForegroundColor = ConsoleColor.Red; | |
Console.WriteLine("Start as Administrator..."); | |
Console.ReadKey(); | |
return; | |
} | |
Console.ForegroundColor = ConsoleColor.Green; | |
Console.WriteLine("Seeking ModernWarfare process..."); | |
Process proc = null; | |
for(; ; ) | |
{ | |
var processes = Process.GetProcessesByName("ModernWarfare"); | |
if (processes.Any()) | |
{ | |
proc = processes.First(); | |
Console.WriteLine($"Process Located with PID {proc.Id}"); | |
DateTime start = DateTime.Now; | |
while(proc.PriorityClass != ProcessPriorityClass.High && (DateTime.Now - start).TotalMinutes < 2) | |
{ | |
System.Threading.Thread.Sleep(250); | |
proc = Process.GetProcessById(proc.Id); //refresh data | |
} | |
proc.PriorityClass = ProcessPriorityClass.Normal; | |
Console.WriteLine($"Corrected priority of ModernWarfare instance with pid: {proc.Id}"); | |
proc.WaitForExit(); | |
Console.WriteLine("Seeking ModernWarfare process..."); | |
} | |
System.Threading.Thread.Sleep(250); | |
} | |
} | |
} | |
} |
Hello Francis.
How does this fix work? Is there working exe that we can run? If you can provide the steps on how to use the code you wrote.
Thanks
Hey @Web1017,
All this did was change the process priority.
I haven't played recently, so I'm not sure if it's still necessary.
Hello Francis.
I understand that. Im asking how it's possible to use this code in the game. I believe it's still necessary as the CPU is still being run at "High" and not "Normal".
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No problem!