PowerShell如何打开文件选择窗口
Add-Type -AssemblyName System.Windows.Forms
$initialDirectory = [Environment]::GetFolderPath( 'MyDocuments' )
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.InitialDirectory = $initialDirectory
$OpenFileDialog.Filter = 'Batch files (*.bat;*.cmd)|*.bat;*.cmd'
$OpenFileDialog.Multiselect = $false
$response = $OpenFileDialog.ShowDialog( ) # $response will be OK or Cancel
if ( $response -eq 'OK' ) { Write-Host 'Selected file:' $OpenFileDialog.FileName }
日期:2020-04-11 23:04:34 来源:oir作者:oir