私はJenkinsを知らないが、ミリ秒で指定されたタイムアウト間隔後に消滅するMessageboxを示すPowerShell関数がここにある。このポップアップにはブロックされません。
function Show-Messagebox
{
param([String]$Title, [String]$Message, [Int]$TimeOut=2000)
$TypeDef = @'
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class Win32API
{
private const UInt32 WM_CLOSE = 0x0010;
[DllImport("user32.dll", EntryPoint="FindWindow", SetLastError = true)]
private static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
[DllImport("user32.Dll")]
private static extern int PostMessage(IntPtr hWnd, UInt32 msg, int wParam, int lParam);
public static void ShowMessageBox(string Message, string Caption, int TimeOut = 2000)
{
var timer = new System.Timers.Timer(TimeOut) { AutoReset = false };
timer.Elapsed += delegate
{
IntPtr hWnd = FindWindowByCaption(IntPtr.Zero, Caption);
if (hWnd.ToInt32() != 0) PostMessage(hWnd, WM_CLOSE, 0, 0);
};
timer.Enabled = true;
MessageBox.Show(Message, Caption);
}
}
'@
Add-Type -TypeDefinition $TypeDef -ReferencedAssemblies System.Windows.Forms
[Win32API]::ShowMessageBox($Message, $Title, $TimeOut)
}
機能はそれほどのように呼び出すことができます。
Show-Messagebox -Title "The Title" -Message "The complete message"
これは、関数にここに文字列としてC#コードでクラスの全種類の定義を入れて持っ少し不器用だ(そこなしここの文字列の最後の記号 '@の前に白いスペースが許されていますが)それでもまだ単純なコピー&のペーストソリューションです。
[System.Windows.Forms.MessageBox] :: Show() - 呼び出しをこの関数で置き換えたPoweShellスクリプトでは、メッセージボックスをブロックする必要はありません。