本帖最后由 ivor 于 2017-12-18 14:43 编辑
代码转载于网络
批处理取返回值:- @echo off
- set pscmdline='powershell.exe -file E:\python\ps.ps1'
- rem 取返回值%%a
- for /f %%a in (%pscmdline%) do (echo %%a)
复制代码 powershell- function Select-FolderDialog
- {
- param([string]$Directory,[string]$Description,[boolean]$ShowNewFolderButton)
- [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
- $objForm = New-Object System.Windows.Forms.FolderBrowserDialog
- $objForm.RootFolder = $Directory
- $objForm.Description = $Description
- $objForm.ShowNewFolderButton = $ShowNewFolderButton
- $Show = $objForm.ShowDialog()
- If ($Show -eq "OK")
- {
- #确定按钮代码块
- Return $objForm.SelectedPath
- }
- Else
- {
- #需要输出错误信息的话可以取消下一行的注释
- #取消按钮代码块
- #Write-Error "error information here"
- }
- }
- $folder_path = Select-FolderDialog -Directory "Desktop" -Description "提示语句" -ShowNewFolderButton $true
- #$folder_path 为选择路径
- return $folder_path
复制代码
|