Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Affinity of an Application on cmd

Tags:

cmd

affinity

I have this problem when I'm using Voicemeeter and Discord together, my voice is just crackling and cutting out. I found out the solution to this problem. It's by going to the task manager, heading to details, right clicking audiodg.exe, and then setting it's affinity to only one processer. The problem is I don't want to do this all by hand everytime I start my computer. Is there any way I can write a line of code into the cmd that changes this? This way I can save this lane as a bat file and then put it into the shell:startup and everytime I turn my computer on it will do it automatically for me.

Thank you so much in advance.

Edit:

I'm sorry I wasn't aware of that. This is the error I get:

C:\Users\borah>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "$Process = Get-Process audiodg.exe; $Process.ProcessorAffinity=1" Get-Process : Cannot find a process with the name "audiodg.exe". Verify the process name and call the cmdlet again. At line:1 char:12

  • $Process = Get-Process audiodg.exe; $Process.ProcessorAffinity=1
  •        ~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (audiodg.exe:String) [Get-Process], ProcessCommandException
    • FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand

The property 'ProcessorAffinity' cannot be found on this object. Verify that the property exists and can be set. At line:1 char:37

  • $Process = Get-Process audiodg.exe; $Process.ProcessorAffinity=1
  •                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound
like image 953
Borahan Gülpınar Avatar asked Oct 19 '25 09:10

Borahan Gülpınar


1 Answers

You can set affinity by typing a command, like following,

Start /affinity 2 notepad

This will start notepad while setting an affinity to second core of CPU.

enter image description here

You can save the command above in a file ending with .cmd and run it by double clicking like any other application. Or you can use task scheduler to launch it with windows startup every time, or you can run it as a startup application.

Edit

If you meant changing affinity of an already running process. Check Mofi's comment as solution.

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "$Process = Get-Process audiodg; $Process.ProcessorAffinity=1"
like image 117
Abdullah Leghari Avatar answered Oct 22 '25 03:10

Abdullah Leghari