获取从资源管理器菜单到Powershell变量的文件夹路径 [英] get a folder path from the explorer menu to a powershell variable
本文介绍了获取从资源管理器菜单到Powershell变量的文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从powershell打开资源管理器窗口并将在资源管理器中选择的路径存储到变量中?
is it possible to open a explorer window from powershell and store the path selected in the explorer, to a variable?
从Powershell打开资源管理器窗口
to open explorer window from powershell
PS C:>资源管理器
PS C:> explorer
推荐答案
也许此脚本是您想要的:
Maybe this script is what you want:
Function Select-FolderDialog
{
param([string]$Description="Select Folder",[string]$RootFolder="Desktop")
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") |
Out-Null
$objForm = New-Object System.Windows.Forms.FolderBrowserDialog
$objForm.Rootfolder = $RootFolder
$objForm.Description = $Description
$Show = $objForm.ShowDialog()
If ($Show -eq "OK")
{
Return $objForm.SelectedPath
}
Else
{
Write-Error "Operation cancelled by user."
}
}
用作:
$folder = Select-FolderDialog # the variable contains user folder selection
这篇关于获取从资源管理器菜单到Powershell变量的文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文