# Chemins de base $ServicesPath = "$($PSScriptRoot)\VNode\services" $VAppPath = "$($PSScriptRoot)\VApp" # Liste des services $JsServices = @( "score-manager.js", "quizz-collector.js", "buzzer-manager.js", "buzzer-watcher.js", "session-manager.js" ) # Utilisation de -d (startingDirectory) pour wt.exe # Cela évite de faire le Set-Location manuellement $WtArguments = "nt --title VultureGame -d `"$($VAppPath)`" powershell.exe -NoExit -Command `"npm run dev -- --host`"" # Boucle pour ajouter chaque service foreach ($ServiceName in $JsServices) { # Recherche du fichier $ServiceSearch = Get-ChildItem -Path "$($ServicesPath)" -Filter "$($ServiceName)" -Recurse | Select-Object -First 1 if ($ServiceSearch) { # On définit le répertoire de travail sur le dossier du script trouvé $Directory = $ServiceSearch.DirectoryName $NodeCommand = "node $($ServiceSearch.FullName)" $WtArguments += " `; nt --title $($ServiceName) -d `"$($Directory)`" powershell.exe -NoExit -Command `"$($NodeCommand)`"" } } # Lancement final Start-Process "wt.exe" -ArgumentList $WtArguments