Play some music COM music

PowerShell can make use of the .NET Framework, and can load assemblies using the Load function in System.Reflection.Assembly. Also, PowerShell can also use any COM class that is registered on your system. This feature gives you the ability to automate applications like Microsoft Word and Excel, or why not Windows Media Player? An error will be thrown if you specify an unexisting COM type name. This code will create an instance of Windows Media Player, if you have it installed:

$player = New-Object -ComObject WMPLAYER.OCX

Then, the Windows Media Player API is at your fingertips, as described on MSDN. This command will give you some kick ass rock:

$player.URL = "F:\Music\ACDC - Who made who.mp3"

Enjoy!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *