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

后端 未结 5 885
忘掉有多难
忘掉有多难 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:06

    I found the use of reflection in the selected answer to be a little awkward. The link below offers a more direct approach

    http://www.powershellmagazine.com/2013/06/28/pstip-using-the-system-windows-forms-folderbrowserdialog-class/

    Copy and pasted relevant code:

    Add-Type -AssemblyName System.Windows.Forms
    $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
    [void]$FolderBrowser.ShowDialog()
    $FolderBrowser.SelectedPath
    

提交回复
热议问题