Rya*_*Fox 68 unix windows process-management
是否有Windows平台上类似Unix命令的,漂亮的?
我特意在命令行中查找可以使用的内容,而不是任务管理器中的"设置优先级"菜单.
我在谷歌上发现这种情况的尝试已被那些无法想出更好形容词的人所挫败.
Ste*_*cer 61
如果要在启动进程时设置优先级,可以使用内置的start命令:
START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/WAIT] [/B] [command/program] [parameters]
Run Code Online (Sandbox Code Playgroud)
使用低到低于正常的选项来设置已启动命令/程序的优先级.似乎是最直接的解决方案.没有下载或脚本编写.其他解决方案可能适用于已经运行的过程.
如果使用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)`""
}
Run Code Online (Sandbox Code Playgroud)
在PowerShell提示符下,您可以执行以下操作:
set-ProcessPriority SomeProcessName "High"
Run Code Online (Sandbox Code Playgroud)
小智 5
来自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";
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25205 次 |
| 最近记录: |