Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.