System.Windows.Messagebox超时PowerShell的

问题描述 投票:0回答:1

我要问关于暂停时以[System.Windows.MessageBox]代码是下一个:

“logX的”(如LOG1,LOG2或log3中)是功能上写入文件,只改变LOG3。 LOG3做“退出”写后(离开脚本)。我们不需要在如何工作这个功能

#Funcion para comprobar si existe el token o no.
function Token{
#comprobamos si existe el fichero
$token = Test-Path $dir_token
if($token -eq $True){
    #Existe el fichero
    $ftoken = 1
}else{ 
    #No existe el fichero
    $ftoken = 0
}
return $ftoken
}

#Asignamos dirección de token
$Global:dir_token = "D:\Nuevacarpeta\Nueva carpeta\token.txt"
#Ejecutamos la funcion de Token para saber si existe ahora mismo
$ftoken = Token
#Preparamos la ruta del log
$log = "D:\Nuevacarpeta\log\log.txt"

#Creamos la variable Outlook transformandolo en un objeto (Commobject de Powershell)
$Global:outlook = New-Object -comobject outlook.application
$comprobaroutlook = Get-variable -name outlook
$valueoutlook = $comprobaroutlook.Value

if($valueoutlook.Equals("")){

$msgBoxInput =  [System.Windows.MessageBox]::Show('Outlook no se puede tratar, SCRIPT FAIL, para Borrar token y continuar con la ejecución pulsa SI, para no borrar el token e ignorar este mensaje pulse NO','ERROR CRITICO SCRIPT','YesNo','Error')
switch  ($msgBoxInput) {
  'Yes' {
  ## Do something 
  Remove-Item -Path $dir_token
  [System.Windows.MessageBox]::Show("BORRADO TOKEN")
  Log3("Borrado token, proxima ejecución sera correcta")  
  }
  'No' {
  ## Do something
  [System.Windows.MessageBox]::Show("No hacemos nada, esperamos")
  Log3("No tiene contenido la variable outlook")
  }
}
}elseif($ftoken -eq 1){

$msgBoxIn = [System.Windows.MessageBox]::Show('Outlook no se puede tratar, SCRIPT FAIL, para Borrar token y continuar con la ejecución pulsa SI, para no borrar el token e ignorar este mensaje pulse NO','ERROR CRITICO SCRIPT','YesNo','Error')     
switch  ($msgBoxIn) {
  'Yes' {
  ## Do something 
  Remove-Item -Path $dir_token
  [System.Windows.MessageBox]::Show("BORRADO TOKEN")
  Log3("Borrado token, proxima ejecución sera correcta") 
  }
  'No' {
  ## Do something
  [System.Windows.MessageBox]::Show("No hacemos nada, esperamos")
  Log3("Existe Token")
  }
}

}else{

  New-Item -Path $dir_token -ItemType File

}

我问这个通道超时:

- [System.Windows.MessageBox] ::显示( “BORRADO TOKEN”) - [System.Windows.MessageBox] ::显示( “不hacemos虚无缥缈,esperamos”)

此消息其唯一的信息和我想告诉和关闭5分钟后弹出在屏幕

windows powershell popup timeout messagebox
1个回答
0
投票

您可以使用Wscript.Shell COM对象。

$sh = New-Object -ComObject "Wscript.Shell"
$intButton = $sh.Popup("Testing",2,"Title",0+64)

here

句法

  intButton = objShell.Popup(strText,[nSecondsToWait],[strTitle],[nType]) 

参数

objShell:甲WScript.Shell对象

strText:包含要显示在弹出的消息框中的文本字符串值。

nSecondsToWait:的时间的最大长度,以显示弹出消息框(以秒计,可选选项,默认=无穷大)

strTitle:标题文本字符串,可选。

nType:按钮和图标(数字,可选)这些确定如何使用消息框的类型。

IntButton:按钮(整数值)数量这是当用户确定的消息框返回的值。

nType的含义由值从下面的表2组合测定:

键类型

值说明 0 OK按钮。 1个确定和取消按钮。 2放弃,重试和忽略按钮。 3是,否和取消按钮。 4个是和否按钮。 5重试和取消按钮。

图标类型 值说明 16“停止标志”图标。 32“问号”图标。 48“感叹号”图标。 64“信息标记”图标。

对于IntButton返回值可能值:

值说明 1个OK按钮 2取消按钮 3中止按钮 4重试按钮 5忽略按钮 6 Yes按钮 7无按钮

如果说之前nSecondsToWait intButton设置为-1用户没有点击一个按钮。

© www.soinside.com 2019 - 2024. All rights reserved.