So this:
Code:
@ECHO OFF
REG ADD "HKCR\exefile\shell\Run with CPU-4 Affinity" /ve /f
REG ADD "HKCR\exefile\shell\Run with CPU-4 Affinity\Command" /ve /t REG_SZ /d "cmd.exe /c start \"Run with CPU-4 Affinity\" /affinity 5 \"%%1\"" /f
REG ADD "HKCR\exefile\shell\Run with CPU-5 Affinity" /ve /f
REG ADD "HKCR\exefile\shell\Run with CPU-5 Affinity\Command" /ve /t REG_SZ /d "cmd.exe /c start \"Run with CPU-5 Affinity\" /affinity 6 \"%%1\"" /f
REG ADD "HKCR\exefile\shell\Run with CPU-6 Affinity" /ve /f
REG ADD "HKCR\exefile\shell\Run with CPU-6 Affinity\Command" /ve /t REG_SZ /d "cmd.exe /c start \"Run with CPU-6 Affinity\" /affinity 7 \"%%1\"" /f
REG ADD "HKCR\exefile\shell\Run with CPU-7 Affinity" /ve /f
REG ADD "HKCR\exefile\shell\Run with CPU-7 Affinity\Command" /ve /t REG_SZ /d "cmd.exe /c start \"Run with CPU-7 Affinity\" /affinity 8 \"%%1\"" /f
REG ADD "HKCR\exefile\shell\Run with CPU-8 Affinity" /ve /f
REG ADD "HKCR\exefile\shell\Run with CPU-8 Affinity\Command" /ve /t REG_SZ /d "cmd.exe /c start \"Run with CPU-8 Affinity\" /affinity 9 \"%%1\"" /f
REG ADD "HKCR\exefile\shell\Run with CPU-9 Affinity" /ve /f
REG ADD "HKCR\exefile\shell\Run with CPU-9 Affinity\Command" /ve /t REG_SZ /d "cmd.exe /c start \"Run with CPU-9 Affinity\" /affinity 10 \"%%1\"" /f
REG ADD "HKCR\exefile\shell\Run with CPU-10 Affinity" /ve /f
REG ADD "HKCR\exefile\shell\Run with CPU-10 Affinity\Command" /ve /t REG_SZ /d "cmd.exe /c start \"Run with CPU-10 Affinity\" /affinity 11 \"%%1\"" /f
REG ADD "HKCR\exefile\shell\Run with CPU-11 Affinity" /ve /f
REG ADD "HKCR\exefile\shell\Run with CPU-11 Affinity\Command" /ve /t REG_SZ /d "cmd.exe /c start \"Run with CPU-11 Affinity\" /affinity 12 \"%%1\"" /f
..would result in my CPU affinity being set to CPU- 0 to 3 off and CPU- 4 to 11 on?
Can this be done for a specific *.exe only? I mean, can I still let other processes run on CPU- 0 to 3? Is there a way to clean it up a bit? Maybe 2 strings that sets the affinity of all instead of 16, 2 for each processor core.
I know how to add to the registry at the same time as I launch the program, but I don't know how to make the removal batch run automatically when I close the program. How is that done?
***UPDATE***
I found a solution that fits my problem better. I will let the rest of my question stay though, maybe others can get use of that.
This command line sets the CPU affinity for the program as you start it:
C:\Windows\System32\cmd.exe /C start "" /affinity XX "*PATH OF PROGRAM*"
XX = The hexadecimal number for the logical processors you want to use.
1 = use CPU 0
2 = use CPU 1
3 = use CPU 1 and 0
4 = use CPU 2 ...
9 = use CPU 3 and 0
A = use CPU 3 and 1 ...
F = use CPU 3, 2, 1 and 0
If you have a lot of CPUs to choose from you might wanna use binary numbers and convert it to hexadecimal afterwards.
1 = use CPU 0
10 = use CPU 1
100 = use CPU 2
...
100000000000 = use CPU 11
110 = use 1 and 2
101010101010 = use CPU 11, 9, 7, 5, 3 and 1
The placement of a certain digit represents a certain processor. The value of that digit represents if the processor is to be on or off.
You can convert it here:
http://www.mathsisfun.com/binary-dec...converter.html
Hope I helped a little in return for your time