developer tip

'nice'에 해당하는 Windows

optionbox 2020. 11. 12. 08:08
반응형

'nice'에 해당하는 Windows


유닉스 명령의 윈도우 동등한 거기에 좋은 ?

작업 관리자의 "우선 순위 설정"메뉴가 아니라 명령 줄에서 사용할 수있는 것을 구체적으로 찾고 있습니다 .

구글에서 이것을 찾으려는 나의 시도는 더 나은 형용사를 생각할 수없는 사람들에 의해 좌절되었습니다.


프로세스를 시작할 때 우선 순위를 설정하려면 기본 제공 START 명령을 사용할 수 있습니다 .

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

시작된 명령 / 프로그램의 우선 순위를 설정하려면 낮음에서 보통 이하 옵션을 사용합니다. 가장 간단한 솔루션 인 것 같습니다. 다운로드 나 스크립트 작성이 없습니다. 다른 솔루션은 이미 실행중인 procs에서 작동합니다.


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"

설정에 따라 프로세스 우선 순위를 다운 그레이드하거나 업그레이드하는 프로세스를 "자동화"하는 ProcessTamer 사용을 고려할 수 있습니다.

2 년 동안 사용하고 있습니다. 매우 간단하지만 정말 효과적입니다!


에서 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";
}

PrcView는 명령 줄에서도 작동하는 것 같습니다.

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

(-ph 매개 변수 확인)

참고 URL : https://stackoverflow.com/questions/4208/windows-equivalent-of-nice

반응형