UmeAiRT commited on
Commit
023440a
·
verified ·
1 Parent(s): 28dcf4e

Upload Install-ComfyUI.ps1

Browse files
Files changed (1) hide show
  1. scripts/ComfyUI/Install-ComfyUI.ps1 +23 -3
scripts/ComfyUI/Install-ComfyUI.ps1 CHANGED
@@ -54,13 +54,33 @@ function Write-Log {
54
  }
55
 
56
  function Invoke-AndLog {
57
- param([string]$File, [string]$Arguments)
58
- $commandToRun = "`"$File`" $Arguments"
59
- $cmdArguments = "/C `"$commandToRun >> `"`"$logFile`"`" 2>&1`""
 
 
 
 
 
60
  try {
 
 
 
61
  Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden
 
 
 
 
 
 
 
62
  } catch {
63
  Write-Log "FATAL ERROR trying to execute command: $commandToRun" -Color Red
 
 
 
 
 
64
  }
65
  }
66
 
 
54
  }
55
 
56
  function Invoke-AndLog {
57
+ param(
58
+ [string]$File,
59
+ [string]$Arguments
60
+ )
61
+
62
+ # Chemin vers un fichier de log temporaire unique
63
+ $tempLogFile = Join-Path $env:TEMP ([System.Guid]::NewGuid().ToString() + ".tmp")
64
+
65
  try {
66
+ # Exécute la commande et redirige TOUTE sa sortie vers le fichier temporaire
67
+ $commandToRun = "`"$File`" $Arguments"
68
+ $cmdArguments = "/C `"$commandToRun > `"`"$tempLogFile`"`" 2>&1`""
69
  Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden
70
+
71
+ # Une fois la commande terminée, on lit le fichier temporaire
72
+ if (Test-Path $tempLogFile) {
73
+ $output = Get-Content $tempLogFile
74
+ # Et on l'ajoute au log principal en toute sécurité
75
+ Add-Content -Path $logFile -Value $output
76
+ }
77
  } catch {
78
  Write-Log "FATAL ERROR trying to execute command: $commandToRun" -Color Red
79
+ } finally {
80
+ # On s'assure que le fichier temporaire est toujours supprimé
81
+ if (Test-Path $tempLogFile) {
82
+ Remove-Item $tempLogFile
83
+ }
84
  }
85
  }
86