Skip to content

Instantly share code, notes, and snippets.

@stduhpf
Created March 31, 2023 14:37
Show Gist options
  • Save stduhpf/897683b2c09d26619448206dee510682 to your computer and use it in GitHub Desktop.
Save stduhpf/897683b2c09d26619448206dee510682 to your computer and use it in GitHub Desktop.
Play notification sound from powershell script
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class SoundPlayer {
[DllImport("winmm.dll")]
public static extern bool PlaySound(string pszSound, IntPtr hmod, uint fdwSound);
}
"@
# You can change the path to any wav file you want to play
[void][SoundPlayer]::PlaySound("C:\Windows\Media\tada.wav", [System.IntPtr]::Zero, 0x20000)
#!/bin/bash
# Call the "tada.ps1" powershell script from WSL's shell
powershell.exe -ExecutionPolicy Bypass -File tada.ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment