1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| if (!(net session)) {$path = "& '" + $myinvocation.mycommand.definition +
"'" ; Start-Process powershell -windowstyle hidden -Verb runAs -ArgumentList $path ; exit}
$PathDir="C:\Users\\Desktop\powershell\"
$File_dot_source_core = $PathDir + "file_dot_source_core.ps1"
$File_dot_source_priority = $PathDir + "file_dot_source_priority.ps1"
function ExistFile($F){
if ( (Test-Path $F) -eq $False ){
Write-Host "Le fichier n'existe pas:" $F
Start-Sleep -Seconds 5
exit 1
}
}
ExistFile $File_dot_source_core
ExistFile $File_dot_source_priority
$P6 = 256 #real time
$P5 = 128 #high priority
$P4 = 32768 #above normal
$P3 = 32 #normal
$P2 = 16384 #below normal
$P1 = 64 #idle
$CORE_1=1
$CORE_2=2
$CORE_3=4
$CORE_4=8
$CORE_5=16
$CORE_6=32
$CORE_7=64
$CORE_8=128
$CORE_ALL=255
#code
function MySwitchPriority($Name, $P){
#ne gère pas les erreur si un process n'existe pas
$MesProcess = Get-WmiObject Win32_process -filter "name = ""$Name"""
foreach ($OneProcess in $MesProcess){
write-host $OneProcess.priority
$OneProcess.SetPriority($P) > $null
}
}
function MyCore($SetName, $C){
write-output $SetName
if((get-process $SetName -ea SilentlyContinue) -eq $Null)
{
write-output "MyCore: Processus introuvable $SetName"
return
}
$GetProcess = Get-Process $SetName -ErrorAction SilentlyContinue
$GetProcess | Foreach-Object {$_.ProcessorAffinity=$C} > $null
}
#Import-Module $File_conf_core_normal
. $File_dot_source_core
. $File_dot_source_priority
function Profil_Normal(){
BuildCore "Normal"
BuildPriority "Normal"
}
function Profil_Game(){
BuildCore "Game"
BuildPriority "Game"
}
function Profil_Brave(){
BuildCore "Brave"
BuildPriority "Brave"
}
function Profile_BraveDiscord(){
BuildCore "BraveDiscord"
BuildPriority "BraveDiscord"
}
Profil_Game |
Partager