When you use this option, you don't have to enter a password when you save the task. But it only will run when you are logged on. And if the task launches a GUI program, then its window will be visible to the desktop user.
If you are not logged on, then the task won't launch.
If you set this option, then the task should run as soon as you log on to the desktop.
If you want the task to run even if you are not logged on, you need to set this option. When you save the task it will prompt you for a password. If the task runs a GUI program, the window will NOT be visible. That's why it's best to run command line based programs, because if a GUI displays a message box, there is no way to "click on OK to continue".
I tested playing a .wav file and found that just putting the file name in the bat file launches the GUI Media Player which plays it (on my Win11). But MP does not terminate. If the task runs "while logged on", that's not a problem because the desktop user can click on the X to close the window.
But if the task runs whether the user is logged on or not, then you would need to use taskkill.exe to make Media Player terminate.
I found a Powershell script to play a .wav/.mp3 file. I put your file name in it.
Add-Type -AssemblyName presentationCore
$mediaPlayer = New-Object system.windows.media.mediaplayer
$mediaPlayer.open("C:\Users\norav\Music\Silence_6H.wav")
$mediaPlayer.Play()
"Playing wav"
# wait for media player to finish
while ($mediaPlayer.Position.TotalMilliseconds -ne $mediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds) {
start-sleep -Seconds 2
}
"Its finished."
So if you save that as C:\Users\norav\Desktop\PlayWav.ps1, then in your .bat file you would call this.
powershell.exe -executionpolicy bypass -file C:\Users\norav\Desktop\PlayWav.ps1
Hope that helps you.