Reputation: 521
How should I set the priority of a different application running on the computer in c# win form. I'm a little new to this website and coding all together.
System.Diagnostics.Process.Start("cmd.exe","wmic process where name=\"HD-Frontend.exe\" CALL setpriority 32");
Is what I've tried so far. Just didn't work... :(
Upvotes: 1
Views: 2093
Reputation: 19863
setpriority 32 appears to be a linux call
What you need to do is get the Process handle from Start like this
Process myProcess = Process.Start("cmd.exe", "wmic process where name=\"HD-Frontend.exe\"");
Then play with the priority once you have the handle
myProcess.PriorityClass = RealTime;
Alternatively, you could define your process before starting it and edit the priority before it has started
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.PriorityClass = RealTime;
myProcess.Start();
Look at the ProcessPriority property of Process
Upvotes: 2