Advertisement
Raimonds

msg_ok_dontwait.ps1

Mar 18th, 2016
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Default params if no input given.
  2. param (
  3.     [string]$txtFileName="default",
  4.     [int]$duration=0,
  5.     [string]$title="CompanyName IT"
  6. )
  7.  
  8. #Path to message repo
  9. $msgPath = ("\\namespace\it\deploy\_messages\" + $txtFileName + ".txt")
  10.  
  11. #exit early if txt file doesn't exist
  12. If (-Not (Test-Path $msgPath)) {
  13.     exit 1
  14. }
  15.  
  16. $msg = Get-Content -Path $msgPath | Out-String
  17.  
  18. #Spawns a new job allowing current script to exit succesfully.
  19. #Doesn't work with PDQ for some reason
  20. Start-Job -ScriptBlock {
  21.     param ($msg, $duration, $title)
  22.     $a = new-object -comobject wscript.shell
  23.     $intAnswer = $a.popup($msg,$duration,$title,0+32+4096)
  24.     get-job | remove-job
  25. } -ArgumentList $msg,$duration,$title | Out-Null
  26.  
  27. return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement