It also requires your script to be saved to a file, of course. Note that $PSScriptRoot requires PowerShell version 3.0 or later. NET Framework does not contain many types. With the System.Media namespace, you can use this type to load any WAV file. SoundLocation = " $PSScriptRoot\mySound.wav " $player. The SoundPlayer type plays sounds or music. This example would playback the file mySound.wav that is located in the same folder as your script: $player = New-Object -TypeName $player. If you'd like to ship a custom sound with your PowerShell script, simply place it into the same folder together with your script, and use $PSScriptRoot to reference the folder your script is located in. Once your script is done, it can stop playback using this call: $player. SoundLocation = ' C:\Windows\Media\chimes.wav ' $player. This would play a sound repeatedly: $player = New-Object -TypeName $player. It accepts a path to a WAV file and lets you then decide whether you want to play the sound once or repeatedly. To play a WAV sound file in a background process, PowerShell can use the built-in SoundPlayer class.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |