Skip to content

Instantly share code, notes, and snippets.

@francisrohner
Created December 16, 2019 00:33
Show Gist options
  • Save francisrohner/ea28a41f9b1c9cad8119c90830cccaea to your computer and use it in GitHub Desktop.
Save francisrohner/ea28a41f9b1c9cad8119c90830cccaea to your computer and use it in GitHub Desktop.
Fix process priority for Modern Warfare
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);
}
}
}
}
@SpacePoodle
Copy link

Pretty cool! Thanks bro.

@francisrohner
Copy link
Author

No problem!

@Web1017
Copy link

Web1017 commented Jan 4, 2022

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

@francisrohner
Copy link
Author

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.

@Web1017
Copy link

Web1017 commented Jan 11, 2022

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