Search code examples
windowspowershellaffinity

in powershell, set affinity in start-process


In powershell, I can launch a process with

$app_name = "app.exe"
$app_arguments = "arg0"
Start-Process $app_name $app_arguments

I try set the affinity with

$app = Start-Process $app_name $app_arguments
$app.ProcessorAffinity = 0x3

.... no work.

In windows powershell, when I launch a process how I can set the affinity ?


Solution

  • I can solve with

    $app_name = "app.exe"
    $app_arguments = "arg0"
    
    $pinfo = New-Object System.Diagnostics.ProcessStartInfo
    $pinfo.FileName = $app_name
    $pinfo.Arguments = $app_arguments
    $p = New-Object System.Diagnostics.Process
    $p.StartInfo = $pinfo
    $p.Start()
    $p.ProcessorAffinity=0x3