mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-26 14:26:10 +01:00
Added play-system-sounds.ps1
This commit is contained in:
parent
360947b911
commit
5ca003c8e3
33
scripts/play-system-sounds.ps1
Normal file
33
scripts/play-system-sounds.ps1
Normal file
@ -0,0 +1,33 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Plays all system sounds
|
||||
.DESCRIPTION
|
||||
This PowerShell script plays all operating system sounds.
|
||||
.EXAMPLE
|
||||
PS> ./play-system-sounds.ps1
|
||||
(listen and enjoy)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
function PlaySoundFiles([string]$filePattern) {
|
||||
$files = (Get-ChildItem "$filePattern")
|
||||
foreach($file in $files) {
|
||||
& "$PSScriptRoot/play-mp3.ps1" "$file"
|
||||
Start-Sleep -milliseconds 500
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$WinDir = Resolve-Path "$env:WINDIR"
|
||||
if (-not(Test-Path "$WinDir" -pathType container)) { throw "Windows directory at 📂$Path doesn't exist" }
|
||||
|
||||
PlaySoundFiles "$WinDir\Media\*.wav"
|
||||
PlaySoundFiles "$WinDir\Media\*\*.wav"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user