Can't get custom sounds to work #258
-
|
Hi there A bit of a powershell noob, so apologies if this is a dumb question I've been writing a powershell script to perform disk checks across my system on a regular basis. The script functions correctly, but I wanted it to play some custom sounds from a videogame (X-COM Interceptor) when it reaches certain points so I know what's going on even if I don't see the notification. I've gone over the syntax again and again and just get errors no matter what. Here's an example New-BurntToastNotification -AppLogo "C:\Users\redacted\Documents\DISM & SFC logs\Resources\spanner.jpg" -Header (New-BTHeader -Title "Chkdsk in progress") -Text "Running Chkdsk - DO NOT TURN OFF YOUR COMPUTER" -Sound New-BTAudio -Source 'C:\Users\redacted\Documents\DISM & SFC logs\Resources\Interceptor computer\Warning.wav'And I get this I've also tried creating it as an object then calling that Warning = New-BTAudio -Source 'C:\Users\redacted\Documents\DISM & SFC logs\Resources\Interceptor computer\Warning.wav'For this I get variations of this error I tried without '-Sound' and that also doesn't work, gaaaaah!!! I have a bit of C++ knowledge but only very basic powershell knowledge |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 5 replies
-
|
Unfortunatly, the use of custom sounds was removed (at least the ability to just provide a path to a .WAV file) from the Windows Notifications API in some version of Windows 10 and so it was also removed from this project. For applications, it's possible to use a custom sound bundled inside it's "appx" bundle... but unfortunately, that doesn't apply here. All that is to say we're limited to the sounds available by default to Windows Notifications, which you can select like this: $Sound = New-BTAudio -Source 'ms-winsoundevent:Notification.Reminder'In most editors you can see the list of supported sounds by pressing Ctrl + Space after tje |
Beta Was this translation helpful? Give feedback.
-
|
Ah that's a shame... but may not necessarily be a death knell for my idea
So I have already customised a lot of my windows default sounds with these wav files, would it be possible to call them that way? For example, In the old school sound control panel, under Windows is a program event called 'Exclamation', which already plays one of the custom sound files I was trying to use.
Are any of these program event sounds accessible through burnt toast code? I see that it's not listed in the code you linked (it should be ms-winsoundevent:Notification.Exclamation if I'm not mistaken), so would it be fairly easy for me to modify that myself? I have absolutely no idea where this file is, but that should be doable in theory right?
If so, can you direct me to where the file is so I can modify it myself?
Edit: Also when you say '$Sound' Is that to say this is a placeholder object name, and I can name it whatever I want then call it as an object/function?
…________________________________
From: Josh King ***@***.***>
Sent: 23 July 2025 15:23
To: Windos/BurntToast ***@***.***>
Cc: foxhound525 ***@***.***>; Author ***@***.***>
Subject: Re: [Windos/BurntToast] Can't get custom sounds to work (Discussion #258)
Unfortunatly, the use of custom sounds was removed (at least the ability to just provide a path to a .WAV file) from the Windows Notifications API in some version of Windows 10 and so it was also removed from this project. For applications, it's possible to use a custom sound bundled inside it's "appx" bundle... but unfortunately, that doesn't apply here.
All that is to say we're limited to the sounds available by default to Windows Notifications, which you can select like this:
$Sound = New-BTAudio -Source 'ms-winsoundevent:Notification.Reminder'
In most editors you can see the list of supported sounds by pressing Ctrl + Space after tje -Source and choose from the list. Otherwise it's also in the code here<https://github.com/Windos/BurntToast/blob/73ec8aca95640a56c4ff4b5cb30479bdd6887978/src/Public/New-BTAudio.ps1#L49>
—
Reply to this email directly, view it on GitHub<#258 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/APOWEMUGF2WOVQOUYE4WXP33J6LH3AVCNFSM6AAAAACCFYDKPGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGOBWGQ2DENQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Unfortuntly, Exclamation isn't an option. The list of available ones are here: https://learn.microsoft.com/en-us/uwp/schemas/tiles/toastschema/element-audio In my looking at it, if you can find the mapping between one of those options and the option in the windows default sounds, then the customization there will come through. This means you may be able to pick something you don't expect to get normally. e.g. if you set the audio to 'SMS' in BurntToast, and in Windows change the sound for "New Text Message Notification" then you'll get your desired sound.
Re |
Beta Was this translation helpful? Give feedback.
-
|
BTW, would you mind if I referenced this discussion in a blog post/docs? Tweaking the Windows Sounds in order to get custom audio is a good topic to write about! |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for thr recommendations, I'll give that a go.
And yeah, feel free to reference this. Let me know if/when you publish it so I can have a read too!
Sent from Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Josh King ***@***.***>
Sent: Thursday, July 24, 2025 2:17:07 AM
To: Windos/BurntToast ***@***.***>
Cc: foxhound525 ***@***.***>; Author ***@***.***>
Subject: Re: [Windos/BurntToast] Can't get custom sounds to work (Discussion #258)
BTW, would you mind if I referenced this discussion in a blog post/docs? Tweaking the Windows Sounds in order to get custom audio is a good topic to write about!
—
Reply to this email directly, view it on GitHub<#258 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/APOWEMWIM36RWR6WNMTTZ6L3KAXZHAVCNFSM6AAAAACCFYDKPGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGOBWHE3DIMI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
I still can't get the sound to work Ideally I want to create a variable that I can call with the variable name, rather than writing it out in full every time, but whether I try that, or do it in full, everything I've tried just gives me errors. I customised the SMS sound btw, so thats what I'm trying to call. Can you give me an example of both methods, if its not too much trouble? I can't seem to get the syntax right no matter how I write it. So, if I create a variable like this SMS_Sound = New-BTAudio -Source ms-winsoundevent:Notification.SMS And I want to call it on my notification: How do I declare the variable then call it? And if I want to write it in full along with the notification, how do I do that? Everything else has been really straight forward but I just cant get this to work at all This might be a lack of powershell syntax knowledge at play here but I'm really stuck |
Beta Was this translation helpful? Give feedback.
-
|
If you're using the New-BurntToastNotification -AppLogo "C:\Users\redacted\Documents\DISM & SFC logs\Resources\spanner.jpg" -Header (New-BTHeader -Title "Chkdsk in progress") -Text "Running Chkdsk - DO NOT TURN OFF YOUR COMPUTER" -Sound SMSNote the That function is meant to be a "guided" experience that covers "most" scenarios without needing to worry too much about the internals of things. I'll write up the equivalent of using the "advanced" functions when I get a moment. |
Beta Was this translation helpful? Give feedback.
-
|
Hmmm
I'm still just getting errors.
So I've simplified a bit just to try and get the basics right
```powershell
Start-Transcript -Path "C:\Users\redacted\Documents\DISM & SFC logs\Test Log $(get-date -f dd-MM-yyyy).txt"
$SMS_Sound = New-BTAudio -Source ms-winsoundevent:Notification.SMS
New-BurntToastNotification -Text "Running Chkdsk - DO NOT TURN OFF YOUR COMPUTER" $SMS_Sound
Stop-Transcript
```
Which gives me this error
```
Transcript started, output file is C:\Users\redacted\Documents\DISM & SFC logs\Test Log 27-07-2025.txt
PS>TerminatingError(New-BurntToastNotification): "A positional parameter cannot be found that accepts argument 'Microsoft.Toolkit.Uwp.Notifications.ToastAudio'."
New-BurntToastNotification : A positional parameter cannot be found that accepts argument
'Microsoft.Toolkit.Uwp.Notifications.ToastAudio'.
At C:\Users\redacted\Documents\DISM & SFC logs\Resources\Chkdsk\Test code\test3.ps1:11 char:1
+ New-BurntToastNotification -Text "Running Chkdsk - DO NOT TURN OFF YO ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-BurntToastNotification], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,New-BurntToastNotification
New-BurntToastNotification : A positional parameter cannot be found that accepts argument
'Microsoft.Toolkit.Uwp.Notifications.ToastAudio'.
At C:\Users\redacted\Documents\DISM & SFC logs\Resources\Chkdsk\Test code\test3.ps1:11 char:1
+ New-BurntToastNotification -Text "Running Chkdsk - DO NOT TURN OFF YO ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-BurntToastNotification], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,New-BurntToastNotification
```
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks Josh, it worked!
I'm making some progress with making my script more advanced, and learning some powershell basics along the way.
I've just learned that the pipe operator '|' can be used to break up large lines of instructions to make them more readable, but powershell is throwing an error when I do that using burnt toast notification
For example:
```powershell
New-BurntToastNotification -AppLogo "C:\Users\redacted\Documents\DISM & SFC logs\Resources\spanner.jpg" |
-Header (New-BTHeader -Title "Backup In Progress") |
-Text "Running Backup - HDD 2 (X)" |
-ProgressBar @(New-BTProgressBar -Status 'Backup' -Value 0.0)
```
The above was all on a single line before, making it a pain in the arse to work with as I'm writing multiple scripts and I've got a lot of windows open. Now as soon as it gets to '-Header' it doesn't understand anymore.
Is there a way to improve the formatting like this without breaking the instruction?
|
Beta Was this translation helpful? Give feedback.
-
|
Hi Josh
Since posting this, I had figured out some of the nuance of the pipe character through testing. I also discovered you can use commas to break up some instructions, like long chkdsk instructions with a long list of xd parameters, but that did not work specifically on the burnt toast lines.
What you've provided is very comprehensive and instructive though, and I will absolutely use that splatting method as that looks very elegant and compact!
I can't thank you enough for taking the time to help me out with this, I know its not really your job to do that here, but I am beyond grateful that you've taken the time to teach me.
I've really enjoyed writing PS scripts, and it was burnt toast notifications that took me from cmd prompt to powershell and the wonderful world of scripting.
Thank you dude! You rock!
…________________________________
From: Josh King ***@***.***>
Sent: 03 August 2025 22:27
To: Windos/BurntToast ***@***.***>
Cc: foxhound525 ***@***.***>; Author ***@***.***>
Subject: Re: [Windos/BurntToast] Can't get custom sounds to work (Discussion #258)
You're slightly misunderstanding the | character there. That's the "pipeline" character used to pass the output from one cmdlet or function into another, e.g.:
Get-Service -Name 'example-service' | Stop-Service
You happen to be able to use the pipe for line continuation between commands because the PowerShell engine knows "ok, there's a pipe character, which means I expect to see another command to pass some data into" and it will look through whitespace (including a new line) for that next command. This is why this works:
Get-Service -Name 'example-service' |
Stop-Service
This doesn't work for breaking up paremeters on a single command though. If you must break a command with many parameters onto multiple lines you use the escape character or backtick (`) as that will "escape" the new line character and PowerShell will treat it as a single line. Taking your example above that would be:
New-BurntToastNotification -AppLogo "C:\Users\redacted\Documents\DISM & SFC logs\Resources\spanner.jpg" `
-Header (New-BTHeader -Title "Backup In Progress") `
-Text "Running Backup - HDD 2 (X)" `
-ProgressBar @(New-BTProgressBar -Status 'Backup' -Value 0.0)
However, it is generall frowned upon to use backticks. They're hard to see, easy to miss, and make code harder to maintain (imho). You can read a deepdive on this here<https://get-powershellblog.blogspot.com/2017/07/bye-bye-backtick-natural-line.html>.
What I prefer instead of backticks for dealing with long lines is "splatting<https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting>".
This is where you put your parameters in a hashtable, and then provide that hashtable to the command. Going back to your example that looks like this:
$ToastSplat = @{
AppLogo = "C:\Users\redacted\Documents\DISM & SFC logs\Resources\spanner.jpg"
Header = (New-BTHeader -Title "Backup In Progress")
Text = "Running Backup - HDD 2 (X)"
ProgressBar = (New-BTProgressBar -Status 'Backup' -Value 0.0)
}
New-BurntToastNotification @ToastSplat
Note on there $ToastSplat is just a variable, name it whatever you want. I personally like to include "Splat" in that variable name so that I know the purpose of the variable is to splat some parameters at a command. And then when providing that variable to the command, you use an @ symbol instead of a $, this is what triggers the "splatting" of the parameters instead of a single value.
—
Reply to this email directly, view it on GitHub<#258 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/APOWEMS6DD4IZXKAOB3KOYL3LZ5C5AVCNFSM6AAAAACCFYDKPGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGOJYGAYDMNY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Ok
Spent hours banging my head against this wall and I'm getting nowhere
I'm trying to find a way to compact down notifications that include progress bars, but I can't seem to do that AND update the values of the progress bars too. I've tried everything I can think of and I just cant figure it out.
This is a snip from my code. I've basically refactored all of my code so that I can create a modular template for the various jobs I'm automating, and only need to swap out the name of the drives and the job type. Everything is working, except the progress bars unless I write those out in full every time.
```
$BackupProgressToastSplat =@{
AppLogo = "C:\Users\Redacted\Documents\DISM & SFC logs\Resources\spanner.jpg"
Header = (New-BTHeader -Title "$JobType in progress")
Text = "Running $JobType - $OriginDriveLabel ($OriginDriveLetter) to $DriveLabel ($DriveLetter)"
}
```
```
$ChkdskProgressToastSplat =@{
AppLogo = "C:\Users\Redacted\Documents\DISM & SFC logs\Resources\spanner.jpg"
Header = (New-BTHeader -Title "$JobType in progress")
Text = "Running $JobType - $OriginDriveLabel ($OriginDriveLetter)"
}
```
```
$TestProgressToastSplat =@{
AppLogo = "C:\Users\Redacted\Documents\DISM & SFC logs\Resources\spanner.jpg"
Header = (New-BTHeader -Title "$JobType in progress")
Text = "Running $JobType - $OriginDriveLabel ($OriginDriveLetter) to $DriveLabel ($DriveLetter) - (Not really)"
}
```
```
function Add-ProgressToastSplat {
if("Backup" -eq $JobType)
{New-BurntToastNotification @BackupProgressToastSplat}
if("Chkdsk" -eq $JobType)
{New-BurntToastNotification @ChkdskProgressToastSplat}
if("Test" -eq $JobType)
{New-BurntToastNotification @TestProgressToastSplat}}
```
If I put the progress bar in the first 3 splats, it will come out with whatever value I put in there, but I cant figure out a way to pass a new value into it. I tried adding a dedicated splat for the bar and adding that to the function, but I couldnt get that to work, just threw errors, I didnt even get as far as figuring out how to pass values in.
…________________________________
From: Josh King ***@***.***>
Sent: Sunday, August 03, 2025 22:27
To: Windos/BurntToast ***@***.***>
Cc: foxhound525 ***@***.***>; Author ***@***.***>
Subject: Re: [Windos/BurntToast] Can't get custom sounds to work (Discussion #258)
You're slightly misunderstanding the | character there. That's the "pipeline" character used to pass the output from one cmdlet or function into another, e.g.:
Get-Service -Name 'example-service' | Stop-Service
You happen to be able to use the pipe for line continuation between commands because the PowerShell engine knows "ok, there's a pipe character, which means I expect to see another command to pass some data into" and it will look through whitespace (including a new line) for that next command. This is why this works:
Get-Service -Name 'example-service' |
Stop-Service
This doesn't work for breaking up paremeters on a single command though. If you must break a command with many parameters onto multiple lines you use the escape character or backtick (`) as that will "escape" the new line character and PowerShell will treat it as a single line. Taking your example above that would be:
New-BurntToastNotification -AppLogo "C:\Users\redacted\Documents\DISM & SFC logs\Resources\spanner.jpg" `
-Header (New-BTHeader -Title "Backup In Progress") `
-Text "Running Backup - HDD 2 (X)" `
-ProgressBar @(New-BTProgressBar -Status 'Backup' -Value 0.0)
However, it is generall frowned upon to use backticks. They're hard to see, easy to miss, and make code harder to maintain (imho). You can read a deepdive on this here<https://get-powershellblog.blogspot.com/2017/07/bye-bye-backtick-natural-line.html>.
What I prefer instead of backticks for dealing with long lines is "splatting<https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting>".
This is where you put your parameters in a hashtable, and then provide that hashtable to the command. Going back to your example that looks like this:
$ToastSplat = @{
AppLogo = "C:\Users\redacted\Documents\DISM & SFC logs\Resources\spanner.jpg"
Header = (New-BTHeader -Title "Backup In Progress")
Text = "Running Backup - HDD 2 (X)"
ProgressBar = (New-BTProgressBar -Status 'Backup' -Value 0.0)
}
New-BurntToastNotification @ToastSplat
Note on there $ToastSplat is just a variable, name it whatever you want. I personally like to include "Splat" in that variable name so that I know the purpose of the variable is to splat some parameters at a command. And then when providing that variable to the command, you use an @ symbol instead of a $, this is what triggers the "splatting" of the parameters instead of a single value.
—
Reply to this email directly, view it on GitHub<#258 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/APOWEMS6DD4IZXKAOB3KOYL3LZ5C5AVCNFSM6AAAAACCFYDKPGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGOJYGAYDMNY>.
You are receiving this because you authored the thread.
|
Beta Was this translation helpful? Give feedback.
-
|
Thank you!
…________________________________
From: Josh King ***@***.***>
Sent: Sunday, August 10, 2025 03:49
To: Windos/BurntToast ***@***.***>
Cc: foxhound525 ***@***.***>; Author ***@***.***>
Subject: Re: [Windos/BurntToast] Can't get custom sounds to work (Discussion #258)
Re progress bars, check out this post: https://toastit.dev/2017/04/29/crouton-progress-bars/
That shows how to replace a notification, but the end user experience of that can be jarring (as it will remove the old notification and remove it with a new one.
It is possible to just update the content of a toast notification, rather than replacing it. I demoed this at a user group a long time ago, but the code for this is here: https://github.com/Windos/Talks/blob/main/2021/02%20-%20February/23%20-%20DuPSUG%20-%20Croque%20Monsieur/Demos/06_Update.ps1
And a more specific example of that for toast notifications is here: https://github.com/Windos/Talks/blob/main/2021/02%20-%20February/23%20-%20DuPSUG%20-%20Croque%20Monsieur/Demos/07_Progress.ps1
That uses a function... which is a little envolved but does end up displaying a reasonibly impressive demo: https://github.com/Windos/Talks/blob/main/2021/02%20-%20February/23%20-%20DuPSUG%20-%20Croque%20Monsieur/Demos/Functions/Start-Progress.ps1
—
Reply to this email directly, view it on GitHub<#258 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/APOWEMXMRBH5EKSEWUDE6M33M2XKNAVCNFSM6AAAAACCFYDKPGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMBWGA2TSNY>.
You are receiving this because you authored the thread.
|
Beta Was this translation helpful? Give feedback.
Unfortunatly, the use of custom sounds was removed (at least the ability to just provide a path to a .WAV file) from the Windows Notifications API in some version of Windows 10 and so it was also removed from this project. For applications, it's possible to use a custom sound bundled inside it's "appx" bundle... but unfortunately, that doesn't apply here.
All that is to say we're limited to the sounds available by default to Windows Notifications, which you can select like this:
In most editors you can see the list of supported sounds by pressing Ctrl + Space after tje
-Sourceand choose from the list. Otherwise it's al…