Powershell 2에서 모달이 아닌 Windows.Form/Dialog를 만드는 방법이 있습니까? 양식은 함수 내에서 작성되어야하며 수동으로 닫을 때까지 열려 있어야합니다. 그러나 함수의 실행은 계속되어야합니다. 모든 스크립트 실행이 끝나고 사용자가 대화식 모드로 돌아가더라도 양식을 열린 상태로 유지하는 것이 가능해야합니다.Powershell 함수의 모달이 아닌 양식 생성
나는 이렇게 해봤지만 시작 작업으로 양식을 생성하지도 않는다. 그러나 makeform을 직접 호출하는 것은 예상대로 작동합니다.
function makeform {
[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.Application]::EnableVisualStyles();
$form = New-Object Windows.Forms.Form
$form.Text = 'Test Form'
$form.Add_Shown({$form.Activate()})
$form.ShowDialog()
}
function show {
start-job { makeform }
}
show # does show nothing :| (expected the form to appear)
start-job { makeform } -Name 'myjob' # expect the form to appear here - but it doesn't either :|
Write-Host "Cont..."
# simulate some long running task
[Threading.Thread]::Sleep(10000)
Wait-job myjob
Remove-job myjob
Write-Host "Done..."
Get-Job
중요한 경우에 대비하여 Powershell 2 with .NET 4 (config를 통해)를 실행 중입니다. 고마워요!