Every release of Windows since as far back as I can remember (Windows 3.1) has played a welcome sound at startup. In Windows NT-based systems, there is a startup sound as well as separate logon sound. A sound could also play when Windows logs off or when it shuts down. The user could assign all these sounds from Control Panel -> Sound. Starting with Windows 8, sounds for these events have been eliminated almost entirely. Let's see how to play the lock sound in Windows 10.
Advertisеment
Why Windows 10 doesn't play the lock sound
In Windows 10, Microsoft focused on making Windows boot and shut down faster. Developers of the OS had completely removed the sounds which play at logon, log off and shutdown. Even if you assign sounds to the events for 'Exit Windows', 'Windows Logon' and 'Windows Logoff' or try to restore these events using the Registry, they will not play. There is the official statement from Microsoft which explains the situation.
"We removed these sound events for performance reasons. We pay a lot of attention to how quickly the machine powers on, powers off, goes to sleep, resumes from sleep, etc. As part of speeding this up, we experiment a lot with what process is in control of the startup and shutdown sounds. In an interim build of Windows 8 while it was under development, we were able to speed things up considerably by moving the shutdown sound from Explorer.exe (which is running while you’re still logged on) to Logonui.exe (which is the process that shows the "Shutting down" circle.)
However moving the shutdown sound this late started running into other problems. The code we use to play the sound (the PlaySound API) needs to read from the registry (to see what the preferences for this sound were) and from the disk (to read the .wav file), and we ran into issues where the sound was unable to play (or got cutoff halfway) because we had shut down the registry or the disk already! We could have spent time rewriting the API but we decided the safest and most performant thing to do was to eliminate the sound altogether."
The startup sound
The startup sound remained in Windows 10 but it is disabled by default. You need to enable it manually if required. See the following article:
Enable startup sound in Windows 10
Additionally, Windows 10 comes with a fast startup/hybrid boot feature. Due to this feature, when you click Shut down, it logs you out and hibernates the kernel and powers off; it doesn't really exit Windows. When you turn on your Windows 10 device again, it resumes from hibernate and logs in again. This is different from booting after a full shut down.
Even if you turn on the Windows startup sound, it will only play if you did a full shut down. It never plays when fast startup is on.
The lock sound
Here are instructions to play the Lock sound. This is a sound that Windows plays when you lock your user session/workstation.
The procedure involves several steps. We need to create a special VBScript file which will play the sound, then create a task in Task Scheduler to play it at the lock the workstation event. Here is how.
Create a VBScript File to play the Lock sound
- Open Notepad and paste the following lines into it.
Set oVoice = CreateObject("SAPI.SpVoice") set oSpFileStream = CreateObject("SAPI.SpFileStream") oSpFileStream.Open "C:\Windows\Media\Windows Unlock.wav" oVoice.SpeakStream oSpFileStream oSpFileStream.Close
- Save this file anywhere with a .VBS extension. For example, "LockSound.vbs".
- Double-click the file you've created and ensure that it plays your sound file.
This is a simple VBScript for Windows to play any sound using the Speech API. I prefer this method because it doesn't depend on loading some slow program such as Windows Media Player or any third-party app to play the sound.
In this script, I am using the default sound file, C:\Windows\Media\Windows Unlock.wav
. You can use any file you want. Just modify the appropriate line.
Tip: In the Notepad's Save dialog, include the file name to quotes to ensure that you are saving the file with the VBS file extension and not TXT.
Now we need to create a special Task Scheduler task to play this sound. Task Scheduler is able to run tasks at lock the workstation event, so specifying our script as the task's action will make it play the sound every time you lock your user session.
Play the Lock Sound in Windows 10
- Open Administrative Tools.
- Click the Task Scheduler icon.
- In the Task Scheduler library, click on the Create Task... link on the right.
- In Create Task dialog, fill in the Name box some meaningful text like "Play lock sound".
- Set the option Configure for: Windows 10.
- Switch to the Triggers tab and click on the New... button.
- Set the event for the trigger to On workstation lock.
- Switch to the Actions tab and click on the New... button.
- In the next dialog, set the action type to Start a program.
- In the Program box, specify wscript.exe as the program.
- Type the full path to your VBScript file into the Add arguments text box.
- Switch to the Conditions tab and disable the option Start the task only if the computer is on AC power.
- Click on the OK button to create the task.
Note: If your operating system is preventing you from saving your task due to a blank password, you can add a password to your user account or disable the restriction in Local Security Policy under Administrative tools.
You are done!
This newly assigned sound will play when you lock your computer.
To test the sound in action, just press the Win + L keys. This will lock your workstation and you should hear the sound.
Tip: For extra sound files, check out the WinSounds.com web site. It comes with a large collection of sounds for Windows.
Related articles:
- How to Play the Logon Sound in Windows 10
- How to Play the Shutdown Sound in Windows 10
- Enable startup sound in Windows 10
- How to lock Windows 10 and turn off the display with one click
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!
Advertisеment
thank you
I think I know what Microsoft means by the word ‘performant’ but it isn’t exactly plain English!
I don’t understand why you use VBS here, but PowerShell in Shutdown sound. Wouldn’t PowerShell be the preferred method, seeing as it’s rather more recent than VBS?
See, VBScript is more “lightweight” and faster.
However, during the shutdown, VBScript won’t start. It has some permissions issue and cannot create the speech api object. That’s why I used PowerShell.
So, VBScript is a good idea in most of the cases.
Alright, good enough :-) Thanks for all these “Sounds” articles, I will definitively use them :-)
It worked, thanks a lot. I have every one of the sounds that have been done but I haven’t got logoff. I tried to use a tutorial on YouTube but it didn’t work. I’m not saying you have to, but if you can please could you make a tutorial for the logoff sounds sometime in the near future?