Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Play some music COM music

2012-06-15

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!

Categories: PowerShell

Leave a Reply

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



En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!

Om...

Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   linktr.ee/hesselbom   |   winsoft.se   |   80tal.se   |   Filmtips