Bonjours,

tout est dans le titre, sauf le code

contexte.
je cherche à lancer le script par raccourci sur pression d'une simple touche.
première contrainte:

placer le raccourci sur le bureaux (c'est relou mais bon...)
Comme je modifie les priorités/core sur les processus ça demande une élévation des droits.

j'ai bien l'uac qui me colle sa question:
voulez-vous autoriser cette application à modifier l'ordinateur

donc ça devrait marcher mais non je me prends le message cité dans le titre.
bref voila ce que ça donne:

Code PowerShell : Sélectionner tout - Visualiser dans une fenêtre à part
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

il manque les 2 fichiers qui sont juste les fonction/variable.
Mais l'erreur apparait avant l'uac pose la question, ce qui voudrait dire que le code que j'utilise n'est pas valable.... et la demande se fait trop tard