How to permanently set cpu affinity for programs?

Page 1 of 2 12 LastLast

  1. Posts : 58
    Windows 10 Pro 64-bit
       #1

    How to permanently set cpu affinity for programs?


    Using the command "wmic process where name="mspaint.exe" CALL setpriority128" would set paint to a high priority but what if i want to set the affinity of paint, is there a command for program affinity?

    If not i know process hacker supposedly does the trick but i dont know how accurate and legit process hacker is. Do you guys know any tricks?
      My Computers


  2. Posts : 60
    Win11
       #2
      My Computer


  3. Posts : 873
    Windows 11 x64 23H2 (22631.3527)
       #3

    quicksilverstud said:
    Using the command "wmic process where name="mspaint.exe" CALL setpriority128" would set paint to a high priority but what if i want to set the affinity of paint, is there a command for program affinity?

    If not i know process hacker supposedly does the trick but i dont know how accurate and legit process hacker is. Do you guys know any tricks?
    I use batch scripts to set the affinity and priority.

    How to permanently set cpu affinity for programs?-screenshot-191119003-.png

    Binary/Decimal/Hexadecimal Converter

    Code:
    @echo off
    :: Administrative Permissions Required to Run a Process in Realtime.
    reg query "HKU\S-1-5-19\Environment" >nul 2>&1
    If Not %ERRORLEVEL% EQU 0 (
    powershell.exe -command "Start-Process -FilePath '%0' -Verb runAs"
    exit )
    pushd "%CD%"
    CD /D "%~dp0"
    
    :: Priority Options: Low, Below Normal, Normal, Above Normal, High, Realtime
    :: Affinity Options for Dual Core CPU:
    :: CPU 0+1 (2 Treads) Binary=11 Hexadecimal=3
    :: CPU 0 (1 Tread) Binary=01 Hexadecimal=1
    :: CPU 1 (1 Tread) Binary=10 Hexadecimal=2
    start "" /High /Affinity 2 "mspaint.exe"
    exit

    You can also create a shortcut on the Desktop:
    Code:
     C:\Windows\System32\cmd.exe /c start "" /High /Affinity 1 "C:\Windows\System32\mspaint.exe"
    How to permanently set cpu affinity for programs?-screenshot-191119012-.pngHow to permanently set cpu affinity for programs?-screenshot-191119013-.pngHow to permanently set cpu affinity for programs?-screenshot-191119014-.pngHow to permanently set cpu affinity for programs?-screenshot-191119015-.png
    Last edited by Polo6RGTI; 19 Nov 2019 at 03:44.
      My Computer


  4. Posts : 208
    Win 10
       #4

    Process lasso can handle that and more easy, it is also a legit application.
    Bitsum. Real-time CPU Optimization and Automation

    There is a free version to check out.
      My Computer


  5. Posts : 69,076
    64-bit Windows 11 Pro for Workstations
       #5

    Hello @quicksilverstud,

    If you like, you could create a shortcut using the method in the tutorial below to always open a program with a set CPU Affinity. It still applies to Windows 10.

    CPU Affinity Shortcut for a Program - Create in Windows | Windows 8 Help Forums
      My Computers


  6. Posts : 58
    Windows 10 Pro 64-bit
    Thread Starter
       #6

    Those are all really good ideas thank you everyone
      My Computers


  7. Posts : 69,076
    64-bit Windows 11 Pro for Workstations
       #7

    You're most welcome. Glad we could help.
      My Computers


  8. Posts : 873
    Windows 11 x64 23H2 (22631.3527)
       #8

    quicksilverstud said:
    Those are all really good ideas thank you everyone
    It's a pleasure.
      My Computer


  9. Posts : 20
    Windows 10 Pro
       #9

    Is there a way to achieve permanent affinity for a program that is used without a shortcut? I use the WinFF program for video conversion, which is a UI wrapper around ffmpeg.exe that does the actual converting. So I could set the affinity for WinFF in my WinFF shortcut, but once it starts ffmpeg to do the conversion I've lost that affinity connection because it's a brand new program. I can do it manually, but if I've set WinFF with the task of converting 50 video files, I'd have to set the affinity 50 times.
      My Computers


  10. Posts : 5
    Windows 10 Home Version 1908 Build 18363
       #10

    d4005 said:
    Is there a way to achieve permanent affinity for a program that is used without a shortcut? I use the WinFF program for video conversion, which is a UI wrapper around ffmpeg.exe that does the actual converting. So I could set the affinity for WinFF in my WinFF shortcut, but once it starts FFmpeg to do the conversion, I've lost that affinity connection because it's a brand new program. I can do it manually, but if I'd set WinFF with the task of converting 50 video files, I'd have to set the affinity 50 times.

    I'm answering this old reply for anyone who needs to know how to permanently set affinity without a shortcut file.
    Download System Explorer from this link www.raymond.cc/blog and go to settings, then make sure boot from startup, so that System Explorer will alternatively replace Windows Task Manager but no worries, you are able to revert back to the original task manager.

    Anyway, now all you need to do is select the number of CPU threads and tick the permanent option then done.
    How to permanently set cpu affinity for programs?-system-explorer.jpg

    P.S. There are more alternative task managers to try out on the website if this is not suited to your needs. Enjoy!

    - - - Updated - - -

    Anyhow, I've created this chart which makes it much easier to understand; just enter the hex value H in the command line to enable the number of CPU threads. Also, you can set the priority as well. Enjoy! 😎👍
    Code:
    CPU - HEX  - BINARY
    00 -- 1 ---- 0001
    01 -- 3 ---- 0011
    02 -- 7 ---- 0111
    03 -- F ---- 1111
    04 -- 1F --- 0001 1111
    05 -- 3F --- 0011 1111
    06 -- 7F --- 0111 1111
    07 -- FF --- 1111 1111
    08 -- 1FF -- 0001 1111 1111
    09 -- 3FF -- 0011 1111 1111
    10 -- 7FF -- 0111 1111 1111
    11 -- FFF -- 1111 1111 1111
    12 -- 1FFF - 0001 1111 1111 1111
    13 -- 3FFF - 0011 1111 1111 1111
    14 -- 7FFF - 0111 1111 1111 1111
    15 -- FFFF - 1111 1111 1111 1111
    
    Set Priority:
    High
    AboveNormal
    Normal
    BelowNormal
    Low
    
    Target Location:
    %ComSpec% /C Start /Normal /Affinity H %UserProfile%\AppData\Folder\App.exe

    I haven't tested this app myself, but WinAFC is a configurable program for controlling CPU affinities and priority settings and may be helpful to anyone. Here the download link: www.sourceforge.net/affinitychanger
    How to permanently set cpu affinity for programs?-winafc.jpg

    P.S. Also, the link for WinAFC documentation is here: www.affinitychanger.sourceforge.net
    Last edited by BHeMatrix; 05 Dec 2021 at 16:01.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:27.
Find Us




Windows 10 Forums