代码之家  ›  专栏  ›  技术社区  ›  Ryan Fox

相当于“nice”的窗口

  •  62
  • Ryan Fox  · 技术社区  · 16 年前

    是否存在与unix命令等效的Windows? 美好的 ?

    我专门在命令行中寻找可以使用的东西,并且 任务管理器中的“设置优先级”菜单。

    我在谷歌上找到这个词的尝试被那些无法想出更好形容词的人挫败了。

    5 回复  |  直到 8 年前
        1
  •  58
  •   Markus Safar    9 年前

    如果要在启动进程时设置优先级,可以使用内置的start命令:

    START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
          [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
          [/WAIT] [/B] [command/program] [parameters]

    使用low-through-belownormal选项设置已启动命令/程序的优先级。似乎是最直接的解决方案。没有下载或脚本编写。其他的解决方案可能已经在运行procs了。

        2
  •  6
  •   user247702    8 年前

    如果你使用 PowerShell 您可以编写一个脚本来更改进程的优先级。我在上找到了以下PowerShell函数 Monad blog :

    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提示下,您将执行以下操作:

    set-ProcessPriority SomeProcessName "High"
    
        3
  •  4
  •   ggasp    16 年前

    也许你想考虑使用 ProcessTamer 这将根据您的设置“自动”降级或升级进程优先级的过程。

    我用了两年了。它很简单,但非常有效!

        4
  •  3
  •   Ryan Fox    15 年前

    http://techtasks.com/code/viewbookcode/567

    # 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\n";
    
    $objWMIProcess = Win32::OLE->GetObject('winmgmts:\\\\' . $strComputer . '\\root\\cimv2:Win32_Process.Handle=\'' . $intPID . '\'');
    
    print 'Process name: ' . $objWMIProcess->Name, "\n";
    
    $intRC = $objWMIProcess->SetPriority($intPriority);
    
    if ($intRC == 0) {
        print "Successfully set priority.\n";
    }
    else {
        print 'Could not set priority. Error code: ' . $intRC, "\n";
    }
    
        5
  •  1
  •   Michael Stum    16 年前

    prcview似乎也可以在命令行下工作:

    http://www.teamcti.com/pview/prcview.htm

    (检查-ph参数)