hackoo

Happy_Birthday.bat

Apr 28th, 2021
1,166
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <# : Batch portion
  2. @rem # The previous line does nothing in Batch, but begins a multiline comment block
  3. @rem # in PowerShell.  This allows a single script to be executed by both interpreters.
  4. @echo off & Mode 90,3 & color 9E
  5. CHCP 65001>NUL
  6. Title Playing Happy Birthday song with beep tones in Batch and Powershell by Hackoo 2021
  7. echo(
  8. echo(   Playing Happy Birthday song with beep tones in Batch and Powershell (-_°)
  9. rem # This a Powershell command executes the hybrid portion at the bottom of this script
  10. for /f "delims=" %%I in ('powershell -noprofile "iex (${%~f0}|out-string)"') do set "%%I"
  11. exit /b
  12. rem # End multi-line PowerShell comment block.  Begin PowerShell scripting.
  13. : end Batch / begin PowerShell hybrid code #>
  14.  
  15. $BeepList = @(
  16.     @{ Pitch = 1059.274; Length = 300; };
  17.     @{ Pitch = 1059.274; Length = 200; };
  18.     @{ Pitch = 1188.995; Length = 500; };
  19.     @{ Pitch = 1059.274; Length = 500; };
  20.     @{ Pitch = 1413.961; Length = 500; };
  21.     @{ Pitch = 1334.601; Length = 950; };
  22.  
  23.     @{ Pitch = 1059.274; Length = 300; };
  24.     @{ Pitch = 1059.274; Length = 200; };
  25.     @{ Pitch = 1188.995; Length = 500; };
  26.     @{ Pitch = 1059.274; Length = 500; };
  27.     @{ Pitch = 1587.117; Length = 500; };
  28.     @{ Pitch = 1413.961; Length = 950; };
  29.  
  30.     @{ Pitch = 1059.274; Length = 300; };
  31.     @{ Pitch = 1059.274; Length = 200; };
  32.     @{ Pitch = 2118.547; Length = 500; };
  33.     @{ Pitch = 1781.479; Length = 500; };
  34.     @{ Pitch = 1413.961; Length = 500; };
  35.     @{ Pitch = 1334.601; Length = 500; };
  36.     @{ Pitch = 1188.995; Length = 500; };
  37.     @{ Pitch = 1887.411; Length = 300; };
  38.     @{ Pitch = 1887.411; Length = 200; };
  39.     @{ Pitch = 1781.479; Length = 500; };
  40.     @{ Pitch = 1413.961; Length = 500; };
  41.     @{ Pitch = 1587.117; Length = 500; };
  42.     @{ Pitch = 1413.961; Length = 900; };
  43.     );
  44.  
  45. # I Just added this For..loop in order to listen the beep tones twice (-_°)
  46. For ($i=1; $i -le 2; $i++) {
  47.     foreach ($Beep in $BeepList) {
  48.         Start-Sleep -Milliseconds 20
  49.         [System.Console]::Beep($Beep['Pitch'], $Beep['Length']);
  50.    }
  51. }
RAW Paste Data