When I do this:
I get an obnoxious beep.
When I do any of the below, I expect different sounds, but they are all the same. How do I access the native sounds ?
[System.Media.SystemSounds]::Asterisk.Play()
[System.Media.SystemSounds]::Beep.Play()
[System.Media.SystemSounds]::Exclamation.Play()
[System.Media.SystemSounds]::Hand.Play()
[System.Media.SystemSounds]::Question.Play()(note, I do not want to play a file... I am looking to play sounds native to windows)
31 Answer
This is not a Powershell code issue or feature. It is a Windows OS setting.
Your issue is because they are the default sounds, which are simply a pointer to a .wav file.
If you want those to be different, you have to choose a different .wav file from the Windows folder where they are located.
C:\Windows\Media
So, as for your comment ***note, I do not want to play a file.***, yes, yes you do; but just one that is already on your system default location noted above.
Just go to Control Panel and select Sounds, or right-click the speaker in your taskbar and select sounds. Either way, change as needed manually.
Your options then become this ...
[System.Console]::Beep()
[System.Console]::Beep(1000,300)or this...
(New-Object System.Media.SoundPlayer $(Get-Random $(Get-ChildItem -Path "$env:windir\Media\*.wav").FullName)).Play() 2