Windows Equivalent of 'nice'

windows unix process-management

24407 观看

5回复

7966 作者的声誉

Is there a Windows equivalent of the Unix command, nice?

I'm specifically looking for something I can use at the command line, and not the "Set Priority" menu from the task manager.

My attempts at finding this on Google have been thwarted by those who can't come up with better adjectives.

作者: Ryan Fox 的来源 发布者: 2008 年 8 月 7 日

回应 (5)


1

121006 作者的声誉

PrcView似乎也在命令行中运行:

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

(检查-ph参数)

作者: Michael Stum 发布者: 07.08.2008 12:42

5

917 作者的声誉

也许您想要考虑使用ProcessTamer,根据您的设置“自动化”降级或升级流程优先级的过程。

我已经用了两年了。它非常简单但非常有效!

作者: ggasp 发布者: 07.08.2008 01:21

6

3377 作者的声誉

如果使用PowerShell,则可以编写一个脚本,以便更改进程的优先级。我在Monad博客上找到了以下PowerShell功能:

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"
作者: Chris Miller 发布者: 07.08.2008 02:24

61

1276 作者的声誉

决定

If you want to set priority when launching a process you could use the built-in START command:

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

Use the low through belownormal options to set priority of the launched command/program. Seems like the most straightforward solution. No downloads or script writing. The other solutions probably work on already running procs though.

作者: Stephen Pellicer 发布者: 07.08.2008 02:49

3

0 作者的声誉

来自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";
}
作者: duane 发布者: 23.03.2009 08:17
32x32