====== ファイル選択ダイアログを開いてファイル名を取得する ====== [[:powershell|一つ上へ]] Add-Type -AssemblyName System.Windows.Forms $dialog = New-Object System.Windows.Forms.OpenFileDialog #$dialog.InitialDirectory = [Environment]::GetFolderPath("Desktop") # 初期フォルダ $dialog.InitialDirectory = "C:\Users\username\Downloads" $dialog.Filter = "All files (*.*)|*.*" # フィルタ設定 if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) { $filePath = $dialog.FileName Write-Output "選択されたファイル: $filePath" }