get a folder path from the explorer menu to a powershell variable

后端 未结 5 837
忘掉有多难
忘掉有多难 2021-01-19 04:42

is it possible to open a explorer window from powershell and store the path selected in the explorer, to a variable?

to open explorer window from powershell

5条回答
  •  野的像风
    2021-01-19 05:26

    Here is a solution that opens explorer dialog window, asking user to select a folder. Then stores the folder path inside a variable named "path":

    Add-Type -AssemblyName System.Windows.Forms
    $browser = New-Object System.Windows.Forms.FolderBrowserDialog
    $null = $browser.ShowDialog()
    $path = $browser.SelectedPathode
    

提交回复
热议问题