Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bryanvine
Last active January 10, 2022 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bryanvine/067903f44c74dc8a30d0 to your computer and use it in GitHub Desktop.
Save bryanvine/067903f44c74dc8a30d0 to your computer and use it in GitHub Desktop.
Powershell Wrapped in batch - a simple song using system beeps
goto ExecutePowershell
cls
#Powershell code block begining
#LINK http://www.bryanvine.com/2016/02/powershell-quick-script-wrap-any.html
0..2 | %{
"Loop: $($_+1)"
[System.Console]::Beep(450, 110);[System.Console]::Beep(500, 110);[System.Console]::Beep(550, 110);[System.Console]::Beep(450, 110)
[System.Console]::Beep(675, 200);[System.Console]::Beep(675, 200);[System.Console]::Beep(600, 300);[System.Console]::Beep(450, 110)
[System.Console]::Beep(500, 110);[System.Console]::Beep(550, 110);[System.Console]::Beep(450, 110);[System.Console]::Beep(600, 200)
[System.Console]::Beep(600, 200);[System.Console]::Beep(550, 300);[System.Console]::Beep(525, 110);[System.Console]::Beep(450, 300)
[System.Console]::Beep(450, 110);[System.Console]::Beep(500, 110);[System.Console]::Beep(550, 110);[System.Console]::Beep(450, 110)
[System.Console]::Beep(500, 400);[System.Console]::Beep(600, 300);[System.Console]::Beep(500, 400);[System.Console]::Beep(475, 200)
[System.Console]::Beep(450, 200);[System.Console]::Beep(400, 200);[System.Console]::Beep(600, 500);[System.Console]::Beep(525, 500)
[System.Console]::Beep(450, 110);[System.Console]::Beep(500, 110);[System.Console]::Beep(550, 110);[System.Console]::Beep(450, 110)
[System.Console]::Beep(675, 200);[System.Console]::Beep(675, 200);[System.Console]::Beep(600, 300);[System.Console]::Beep(450, 110)
[System.Console]::Beep(500, 110);[System.Console]::Beep(550, 110);[System.Console]::Beep(450, 110);[System.Console]::Beep(800, 200)
[System.Console]::Beep(500, 200);[System.Console]::Beep(550, 300);[System.Console]::Beep(525, 110);[System.Console]::Beep(450, 300)
[System.Console]::Beep(450, 110);[System.Console]::Beep(500, 110);[System.Console]::Beep(550, 110);[System.Console]::Beep(450, 110)
[System.Console]::Beep(500, 400);[System.Console]::Beep(600, 300);[System.Console]::Beep(500, 400);[System.Console]::Beep(475, 200)
[System.Console]::Beep(450, 200);[System.Console]::Beep(400, 200);[System.Console]::Beep(600, 500);[System.Console]::Beep(525, 500)
}
exit
#end of powershell code - batch code now:
:ExecutePowershell
echo off
set filename=%temp%\Tempscript.ps1
copy /y %0 %filename%
echo NOTE - you will see error output in the error stream about 'goto' - this is expected and can be ignored.
cls
powershell -ExecutionPolicy unrestricted -file %filename% %*
set /a el=%errorlevel%
del %filename%
exit %el%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment