admin管理员组文章数量:1564685
前言
设置之前,先来了解一下Windows进程有哪几种优先级:
Windows进程优先级 | ||
整数值 | 英文名称 | 对应优先级 |
32 | Normal | 正常 |
64 | Idle | 低 |
128 | High Priority | 高 |
256 | Realtime | 实时 |
16384 | Below Normal | 低于正常 |
32768 | Above Normal | 高于正常 |
在XP中,Normal翻译为“标准”而不是“正常”:
只是翻译不同,并无实际区别。Win7里记不得叫什么了,不影响。
本篇以设置Windows自带的“记事本”进程为例。
CMD命令的设置方法
将记事本进程优先级设置为高:
wmic process where "name='notepad.exe'" call setpriority 128
也可以写成这样:
wmic process where "name='notepad.exe'" call setpriority "High Priority"
执行之后如图:
一次设置多个进程:
wmic process where "name='notepad.exe' or name='calc.exe'" call setpriority 128
VBS的操作方法
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_process where name='notepad.exe'")
For Each objProcess In colProcesses
objProcess.SetPriority 128
Next
将上框中的代码,保存为后缀名 .vbs 的文件,如图:
使用时,双击即可。也可以在CMD或者PowerShell中调用。
PowerShell的操作方法
Get-WmiObject Win32_process -filter 'name = "notepad.exe"' | foreach-object {$_.SetPriority(128)}
执行后如图:
版权声明:本文标题:Windows使用命令、脚本设置进程优先级的三种方法 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1726946290a1091161.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论