31 lines
1.6 KiB
PowerShell
31 lines
1.6 KiB
PowerShell
cls
|
||
|
||
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.WindowState = System.Windows.Forms.FormWindowState.Maximized
|
||
$objForm.Rootfolder = $RootFolder
|
||
$objForm.Description = $Description
|
||
$objForm.ShowNewFolderButton = $true
|
||
$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
|
||
|
||
|