弹出警报

本文关键字: | 更新日期: 2023-09-27 17:55:14

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

弹出警报

如果您需要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..
}

在 PowerShell 中,可以创建自定义确认对话框,如下所示:

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
    }
}

所以这里有一个小的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
} 

在这里阅读

相关文章:
  • 没有找到相关文章