批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

[转载代码] [PowerShell每日技巧]创建一个文件夹选择器(20131209)

To add a little glamour to your scripts, here are a few lines of code that display a folder selector dialog. When a user selects a folder, your script receives the selection and can work with the selected path:
  1. Add-Type -AssemblyName System.Windows.Forms
  2. [System.Windows.Forms.Application]::EnableVisualStyles()
  3. $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
  4. $null = $FolderBrowser.ShowDialog()
  5. $Path = $FolderBrowser.SelectedPath
  6. "You selected: $Path"
复制代码
Note the first two lines: they are not necessary when you run the code inside the ISE editor, but you do need them inside the powershell.exe. So keep these lines to make sure your code runs in all PowerShell hosts.

http://powershell.com/cs/blogs/tips/archive/2013/12/09/create-a-folder-selector.aspx

返回列表