Why does a form displayed by PowerShell sometimes not show up?

前端 未结 2 1024
梦如初夏
梦如初夏 2020-12-11 08:10

When I create a form (window) in PowerShell, I can usually display the form using .ShowDialog():

$form = New-Object System.Windows.Forms.Form
$form.ShowDialo         


        
2条回答
  •  感动是毒
    2020-12-11 09:11

    My problem: When using ShowDialog() as part of a powershell logon script, the first form window would not show and powershell would seem to freeze up on logon. Symptoms were simular to the original post.

    Solution I found: Instead of using $form.showDialog(), use:

    [System.Windows.Forms.Application]::Run($form)

    Works great for me now, and only the first form in the series needed the change. All my other forms that come up afterwards in the script still use showDialog.

提交回复
热议问题