Windows是否有与Unix命令等效的Windows,好吗?
我专门在寻找可以在命令行中使用的内容,而不是任务管理器中的"设置优先级"菜单。
那些无法提出更好形容词的人阻止了我在Google上发现此内容的尝试。
 
如果要在启动进程时设置优先级,可以使用内置的START命令:
| 12
 3
 
 | START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED][/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
 [/WAIT] [/B] [command/program] [parameters]
 | 
使用从低到低的低于正常的选项设置启动的命令/程序的优先级。 似乎是最直接的解决方案。 没有下载或脚本编写。 其他解决方案可能适用于已经运行的proc。
如果使用PowerShell,则可以编写脚本来更改进程的优先级。 我在Monad博客上发现了以下PowerShell函数:
| 12
 3
 4
 5
 6
 
 | function set-ProcessPriority { param($processName = $(throw"Enter process name"), $priority ="Normal")
 
 get-process -processname $processname | foreach { $_.PriorityClass = $priority }
 write-host"`"$($processName)`"'s priority is set to `"$($priority)`""
 }
 | 
在PowerShell提示符下,您需要执行以下操作:
| 1
 | set-ProcessPriority SomeProcessName"High" | 
也许您想考虑使用ProcessTamer来根据您的设置"自动"执行降级或升级过程优先级的过程。
我已经使用了两年了。 这很简单,但确实有效!
来自http://techtasks.com/code/viewbookcode/567
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 
 | # This code sets the priority of a process
 # ---------------------------------------------------------------
 # Adapted from VBScript code contained in the book:
 #     "Windows Server Cookbook" by Robbie Allen
 # ISBN: 0-596-00633-0
 # ---------------------------------------------------------------
 
 use Win32::OLE;
 $Win32::OLE::Warn = 3;
 
 use constant NORMAL => 32;
 use constant IDLE => 64;
 use constant HIGH_PRIORITY => 128;
 use constant REALTIME => 256;
 use constant BELOW_NORMAL => 16384;
 use constant ABOVE_NORMAL => 32768;
 
 # ------ SCRIPT CONFIGURATION ------
 $strComputer = '.';
 $intPID = 2880; # set this to the PID of the target process
 $intPriority = ABOVE_NORMAL; # Set this to one of the constants above
 # ------ END CONFIGURATION ---------
 
 print"Process PID: $intPID\
 ";
 
 $objWMIProcess = Win32::OLE->GetObject('winmgmts:\\\\\\\' . $strComputer . '\\\
 oot\\\\cimv2:Win32_Process.Handle=\'' . $intPID . '\'');
 
 print 'Process name: ' . $objWMIProcess->Name,"\
 ";
 
 $intRC = $objWMIProcess->SetPriority($intPriority);
 
 if ($intRC == 0) {
 print"Successfully set priority.\
 ";
 }
 else {
 print 'Could not set priority. Error code: ' . $intRC,"\
 ";
 }
 |