我为参数化的.exe文件编写了PowerShell GUI。 .exe需要使用2个参数运行,即选择的文件和报告格式。 我已经建立了这样的活动:
$VBVGUIValidateButton.Add_Click({
if ($Global:SelectedFile -eq $Null) {
[System.Windows.Forms.MessageBox]::Show("No File Selected. Please select a file !", "Error", 0, [System.Windows.Forms.MessageBoxIcon]::Exclamation)
} else {
if ($VBVGUIXMLReport.Checked -eq "True") {
Choose-Folder
#$ReportString = "$ReportLocation" + "$ReportName" + ".xml"
$ReportString = "$Global:SelectedFolder" + "\" + "$ReportName" + ".xml"
Set-Location -Path $ValidatorPath
.\TOOL.exe /file:$Global:SelectedFile /report:$ReportString /format:xml
[System.Windows.Forms.MessageBox]::Show("Validation process finished !" , "Information", 0, [System.Windows.Forms.MessageBoxIcon]::Information)
} else {
Choose-Folder
#$ReportString = "$ReportLocation" + "$ReportName" + ".html"
$ReportString = "$Global:SelectedFolder" + "\" + "$ReportName" + ".html"
Set-Location -Path $ValidatorPath
.\TOOL.exe /file:$Global:SelectedFile /report:$ReportString
[System.Windows.Forms.MessageBox]::Show("Validation process finished !" , "Information", 0, [System.Windows.Forms.MessageBoxIcon]::Information)
}
}
})
我特别希望在新的CMD窗口中打开/解析.exe文件,以便可以看到TOOL.exe
的过程。
这部分在这里:
Choose-Folder
#$ReportString = "$ReportLocation" + "$ReportName" + ".html"
$ReportString = "$Global:SelectedFolder" + "\" + "$ReportName" + ".html"
Set-Location -Path $ValidatorPath
.\TOOL.exe /file:$Global:SelectedFile /report:$ReportString
[System.Windows.Forms.MessageBox]::Show("Validation process finished !" , "Information", 0, [System.Windows.Forms.MessageBoxIcon]::Information)
如果TOOL.exe
直接执行,则将信息写到CMD中。如果我通过PowerShell GUI执行它,则GUI“冻结”(在后台运行时很明显),并且看不到进度。我该如何实现?