PowerTip: Use PowerShell to play WAV files

The Scripting Guys

Dr

Summary: Make use of the native features of Windows through PowerShell to play sound.

   Hey, Scripting Guy! I’ve got some WAV files I would love to play without launching an application. Is there a way in Windows PowerShell to do this?

     You sure can! Using the System.Media.Soundplayer object, you can do this quite easily. Here is an example of how to do this:

$PlayWav=New-Object System.Media.SoundPlayer

$PlayWav.SoundLocation=’C:\Foo\Soundfile.wav’

$PlayWav.playsync()

Drawing of Dr. Scripto

 

The Scripting Guys
Dr Scripto

Follow Dr   

No Comments.