How to Play Sound when Lock Computer in Windows  

    How to Play Sound when Lock Computer in Windows

    How to Play Sound when Lock Computer in Windows

    Published by Category: Customization
    25 Apr 2021
    Designer Media Ltd

    How to Play Sound when Lock Computer in Windows


    Locking your PC protects it from unauthorized use when you need to step away from the PC, and don't want to sign out or shut down.

    When you lock the computer, you will be taken to the lock screen by default to unlock and sign in when ready to continue where you left off. Other users can still sign in to their accounts from the sign-in screen.

    If you like, you can still create an elevated task to play a sound when users lock the computer.

    This tutorial will show you how to play a sound when users lock the computer in Windows 7, Windows 8, Windows 10.

    You must be signed in as an administrator with a password to create an elevated task.



    Contents

    • Option One: Add or Remove Play a Sound when Lock Computer Task Automatically using a BAT file
    • Option Two: Add or Remove Play a Sound when Lock Computer Task Manually in Task Scheduler






    OPTION ONE

    Add or Remove Play a Sound when Lock Computer Task Automatically using a BAT file


    Special thanks to Matthew for providing the .bat files in this option.


    1 Do step 2 (add) or step 3 (remove) below for what you would like to do.


    2 To Add Play a Sound when Lock Computer Task

    A) Download the Play_Sound_when_Lock_Computer.bat file below to your desktop.
    B) Unblock the downloaded .bat file.

    C) Run the .bat file.

    D) If prompted by UAC, click/tap on Yes to approve running the .bat file elevated (run as administrator).

    E) When prompted, enter the full path of the .wav file you want to play when you lock the computer. (see screenshot below)

    F) When prompted, enter the password for the account to authorize the task.

    G) When finished, press any key to close the command prompt.

    How to Play Sound when Lock Computer in Windows-success.jpg


    3 To Remove Play a Sound when Lock Computer Task

    A) Download the Delete_the_scheduled_task.bat file below to your desktop.
    B) Unblock the downloaded .bat file.

    C) Run the .bat file.

    D) If prompted by UAC, click/tap on Yes to approve running the .bat file elevated (run as administrator).

    E) When finished, press any key to close the command prompt.






    OPTION TWO

    Add or Remove Play a Sound when Lock Computer Task Manually in Task Scheduler


    1 Press the Win + R keys to open Run, type taskschd.msc into Run, and click/tap on OK to open Task Scheduler.

    2 Click/tap on Task Scheduler Library in the left pane of Task Scheduler, and click/tap on Create Task in the right Actions pane. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-1.jpg

    3 In the General tab, type a name (ex: "Play lock sound") you want for this task. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-2.png

    4 In the General tab, select (dot) Run whether user is logged on or not. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-3.png

    5 In the General tab, check the Run with highest privileges box. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-4.png

    6 In the General tab, select your OS (ex: "Windows 10") in the Configure for drop down. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-5.png

    7 Click/tap on the Triggers tab, and click/tap on the New button. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-6.png

    8 Select On workstation lock in the Begin the task drop down, and click/tap on OK. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-7.png

    9 Click/tap on the Actions tab, and click/tap on the New button. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-8.png

    10 Perform the actions below: (see screenshot below)

    A) Select Start a program in the Action drop down.

    B) Type PowerShell in the Program/script field box.

    C) Enter the command below into the Add arguments field box, and click/tap on OK.

    -c (New-Object Media.SoundPlayer 'C:\Windows\Media\Windows Unlock.wav').PlaySync();

    If you wanted to play a sound (.wav file) of your choice instead, you can substitute C:\Windows\Media\Windows Unlock.wav in the command above with the full path of the .wav file you want to be played.

    The Windows Unlock.wav file is not available in Windows 7, but you can download it below if you like.

    Download

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-9.png

    11 Click/tap on the Conditions tab, uncheck the Start the task only if the computer is on AC power box, and click/tap on OK. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-10.png

    12 Enter your account's password, and click/tap on OK. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-11.png

    13 This task (ex: "Play lock sound") is now finished, and will now play a sound when users lock the computer. (see screenshot below)

    How to Play Sound when Lock Computer in Windows-play_sound_at_lock_task-12.png


    That's it,
    Shawn






  1. Posts : 7,607
    Windows 10 Home 20H2
       #1
      My Computer


  2. Posts : 42,983
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #2

    Thanks Shawn, Matthew.. and ..just for fun.. here's a suitable (?) sound file.. from

    Free Doors Sound Effects

    (There is one attached)
      My Computers


  3. Posts : 68,921
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #3

    Thank you @Matthew Wai. Now added as option 1.
      My Computers


 

Tutorial Categories

How to Play Sound when Lock Computer in Windows Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:18.
Find Us




Windows 10 Forums