弹出警报

时间:2013-01-23 10:48:42

标签: c# java .net powershell vbscript

我将要求最终用户使用清理缓存地址 Outlook中的Outlook.exe /CleanAutoCompleteCache命令。 我可以创建一个批处理文件并要求他们点击它。它可以工作,但在继续之前,他们应该弹出警告,运行此文件将删除缓存中的所有地址。

3 个答案:

答案 0 :(得分:1)

如果您需要messagebox,可以将其添加到您的powershell脚本中:

Add-Type -AssemblyName System.Windows.Forms 
$result = [System.Windows.Forms.MessageBox]::Show("if you run this file it will delete all addresses from your cache","Warning", 4)
if ($result -eq "Yes" )
{
  ...do work...
}
else
{
 ..do some other stuff..
}

答案 1 :(得分:0)

在PowerShell中,您可以创建自定义确认对话框shown here

param([string]$title="Confirm",[string]$message="Are you sure?")
$choiceYes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Answer Yes."
$choiceNo = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Answer No."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($choiceYes, $choiceNo)
$result = $host.ui.PromptForChoice($title, $message, $options, 1)
switch ($result)
{
    0 
    {
        Return $true
    }

    1 
    {
        Return $false
    }
}

答案 2 :(得分:0)

所以这是一个小小的PowerShell脚本:

$a = new-object -comobject wscript.shell 
$intAnswer = $a.popup("INFORM USER HERE", 0,"WARNING",1) 
If ($intAnswer -eq 6)
{ 
    //USER OK
} 
else 
{ 
    //USER CANCEL
} 

阅读HERE