I need to ask about timeout with [System.Windows.MessageBox] the code is the next:
"logX" (like log1, log2 or log3) are function to write in a file, only change Log3. Log3 do "exit"(leave the Script) after write. We dont need the how work this function
#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
}
I ask about timeout in this lanes:
-[System.Windows.MessageBox]::Show("BORRADO TOKEN") -[System.Windows.MessageBox]::Show("No hacemos nada, esperamos")
This message its only informative and i wanna show and close it 5 min after popup in the screen