In the mood for some music while working on your windows machines ? Use PowerShell to play your favorite songs with NET classes.
Here’s a code sample you can build on.
Line 1 and 2 plays beeps. Line 4 and 5 plays windows built-in notifications. Last but not least I use the media player to play every song you want in looping mode. To stop the music, I use the stop method of the object.
[System.Console]::Beep(200,1000) [System.Console]::Beep(600,1000) [System.Media.SystemSounds]::Exclamation.play() [System.Media.SystemSounds]::Hand.Play() $player = New-Object System.Media.SoundPlayer "$env:windir\Media\windows logon.wav" $player.PlayLooping() $player.Stop()
Enjoy your favorite songs!
Leave a Reply