×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Bash
Posted by: Jose Fernando Lopez Fernandez
Added: Jun 30, 2018 12:30 AM
Views: 3277
  1.  
  2. $WAVPlayer = New-Object System.Media.SoundPlayer
  3. $WAVPlayer.SoundLocation = "C:\File\Location.wav"
  4. $WAVPlayer.PlaySync()
  5.  
  6. # Note that this will play the entire song, so to kill the process, I've actually been having to open a new pwsh window and use:
  7.  
  8. Get-Process powershell
  9.  
  10. # This will list the process id, which I then kill like this:
  11.  
  12. Stop-Process -Id <id>
  13.  
  14. # Note that I don't simply do Get-Process powershell | Stop-Process because I may have
  15. # multiple powershell windows open and I want to close only the one which is refusing to
  16. # do anything besides play my .wav file
  17.  
  18.  
  19.