June 15th, 2018

PowerTip: Use PowerShell to play WAV files

Doctor Scripto
Scripter

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

 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.