是否可以使用程序快捷方式在 Windows 8.1 中设置程序亲和性而无需打开任务管理器?(通过使用 -setaffinity 之类的命令)
这种方法(改变亲和力)是限制程序 CPU 使用率的好方法吗?
答案1
您可以使用以下方式创建批处理文件
start /affinity 1 PATH_TO_EXE.exe
只需在您的快捷方式中调用此批处理文件即可。这将仅使用 CPU 0 运行它。更改亲和性掩码(这是十六进制值)以获取更多核心。
CPU3 CPU2 CPU1 CPU0 Bin Hex
---- ---- ---- ---- --- ---
OFF OFF OFF ON = 0001 = 1
OFF OFF ON OFF = 0010 = 2
OFF OFF ON ON = 0011 = 3
OFF ON OFF OFF = 0100 = 4
OFF ON OFF ON = 0101 = 5
OFF ON ON OFF = 0110 = 6
OFF ON ON ON = 0111 = 7
ON OFF OFF OFF = 1000 = 8
ON OFF OFF ON = 1001 = 9
ON OFF ON OFF = 1010 = A
ON OFF ON ON = 1011 = B
ON ON OFF OFF = 1100 = C
ON ON OFF ON = 1101 = D
ON ON ON OFF = 1110 = E
ON ON ON ON = 1111 = F
(感谢@Mokubai 指出这一点)
或者,创建快捷方式
C:\Windows\System32\cmd.exe /c start /affinity 1 PATH_TO_EXE.exe