# Godot 4 실행 파일을 찾는다. 못 찾으면 아무것도 내놓지 않는다. # .\find-godot.ps1 그냥 실행판 (창이 뜬다) # .\find-godot.ps1 -Console 콘솔판 (--headless 용, 출력이 보인다) # 찾는 순서: $env:GODOT_BIN > 아래 폴더들 > PATH 위의 godot param([switch]$Console) $dirs = @( "$env:LOCALAPPDATA\Programs\Godot", [Environment]::GetFolderPath('Desktop'), "$env:USERPROFILE\Desktop", "$env:OneDrive\Desktop", "$env:USERPROFILE\Downloads", "$env:ProgramFiles\Godot" ) $found = $null if ($env:GODOT_BIN -and (Test-Path $env:GODOT_BIN)) { $found = $env:GODOT_BIN } if (-not $found) { foreach ($d in $dirs) { if (-not $d -or -not (Test-Path $d)) { continue } # 버전이 올라가도 잡히도록 이름으로 훑고, 높은 버전을 먼저 쓴다 $hit = Get-ChildItem -Path $d -Filter "Godot_v4*_win64.exe" -File -ErrorAction SilentlyContinue | Where-Object { $_.Name -notlike "*_console.exe" } | Sort-Object Name -Descending | Select-Object -First 1 if ($hit) { $found = $hit.FullName; break } } } if (-not $found) { $cmd = Get-Command godot -ErrorAction SilentlyContinue if ($cmd) { $found = $cmd.Source } } if (-not $found) { return } # 찾은 것과 원하는 판이 다르면 짝이 되는 파일로 바꿔 준다 $isConsole = $found -like "*_console.exe" if ($Console -ne $isConsole) { if ($Console) { $alt = $found -replace '\.exe$', '_console.exe' } else { $alt = $found -replace '_console\.exe$', '.exe' } if (Test-Path $alt) { $found = $alt } } return $found