在
Windows中,用
START /node 1 /affinity ff cmd /C "app.exe"
我可以设置app.exe的亲和力(app.exe使用的核心数).
使用Windows脚本,如何更改正在运行的进程的亲和力?
PowerShell可以为您完成此任务
原文链接:/windows/365470.html获得亲和力:
PowerShell "Get-Process app | Select-Object ProcessorAffinity"
设置亲和力:
PowerShell "$Process = Get-Process app; $Process.ProcessorAffinity=255"
示例:(8核处理器)
> Core#= Value = BitMask
>核心1 = 1 = 00000001
>核心2 = 2 = 00000010
>核心3 = 4 = 00000100
>核心4 = 8 = 00001000
>核心5 = 16 = 00010000
>核心6 = 32 = 00100000
>核心7 = 64 = 01000000
>核心8 = 128 = 10000000
只需将十进制值一起添加到您要使用的核心. 255 =全部8个核心.
>所有核心= 255 = 11111111
示例输出:
C:\>PowerShell "Get-Process notepad++ | Select-Object ProcessorAffinity" ProcessorAffinity ----------------- 255 C:\>PowerShell "$Process = Get-Process notepad++; $Process.ProcessorAffinity=13" C:\>PowerShell "Get-Process notepad++ | Select-Object ProcessorAffinity" ProcessorAffinity ----------------- 13 C:\>PowerShell "$Process = Get-Process notepad++; $Process.ProcessorAffinity=255" C:\>
资源:
这是一篇关于如何更改进程亲和力的详细文章:
http://www.energizedtech.com/2010/07/powershell-setting-processor-a.html