Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Affinity of a current process

Status
Not open for further replies.

KM8888

Programmer
Nov 21, 2011
69
US
Hi everyone,

I've scoured the net and didn't find something to work in VBScript for this. I basically want to set the affinity of a current process, e.g. if they are all selected, to only select 1. I found this code for setting the priority which is in the same area as the affinity so I was hoping it was just as easy...

Code:
 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'notepad.exe'")


For Each objProcess  in colProcesses
    objProcess.SetPriority(NORMAL)
Next

Any ideas would be great, thanks!
 
Powershell can do it ...

$Process = Get-Process <app>; $Process.ProcessorAffinity=8

where affinity value is calculated from:

•Core A = 1 = 00000001
•Core B = 2 = 00000010
•Core C = 4 = 00000100
•Core D = 6 = 00001000
•Core E = 8 = 00010000
•Core F = 16 = 00100000
•Core G = 32 = 01000000
•Core H = 64 = 10000000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top