How to mute a Windows PC automatically when it gets locked
Locking a PC can be useful to protect it from being accessed by bystanders while you are away. If you take a break in a work environment for instance, it is always a good idea -- and often company policy -- to lock the PC in question during that time.
While it is easy to lock a Windows PC, the keyboard shortcut Windows-L does that, the locking won't really affect programs running on it.
This means that any sound that plays at the moment continues to play when the device is locked. Again, this can be easily resolved by either stopping the sound manually each time before you lock the PC, by using headsets as it does not really matter in this case.
You may prefer an automated solution on the other hand as it is convenient once set up.
Here is what you need for that:
- The excellent NirCmd which we will use to trigger the functionality when you lock the computer.
- A new task in Windows' Task Scheduler.
Setting it all up
The first thing you may want to do is download and extract NirCmd on the system. You do not need to do anything else with it, just remember the path it is located on as we need that later on.
Open the Windows Task Scheduler next. You can do so by loading a run box with Windows-r, typing taskschd.msc and hitting the enter key.
Or use the search functionality of your operating system and search for Task Scheduler which should also work just fine.
Select Create Task from the actions menu on the right.
Add a name and if you want a description for the task on the general tab that opens up.
Switch to the triggers tab next. Here you need to create two triggers, as you want to mute the sound when you lock the workstation, and unmute it when you unlock it again.
If you only want it muted automatically, you only need to create a single trigger here.
Select new and select on workstation lock and for the next trigger on workstation unlock and leave every other setting as is.
Switch to the actions tab afterwards and click on the new button here. Keep start a program as the action, and browse to the nircmd.exe script on the PC's hard drive.
Add mutesysvolume 2 as the argument and click on ok afterwards.
The command toggles between mute and unmute state of the sound on the system. You find additional examples on the Nirsoft website. The command nircmd.exe mutesysvolume 1Â will mute the volume for instance but not unmute it at a later point in time.
NirCmd is compatible with all supported versions of the Microsoft Windows operating system.
Nice article. Thanks.
Until today I only used “path/nircmd.exe mutesysvolume 1” to mute before going into hibernation via TOff. Your solution seems much better.
Martin, you have done another fine job of describing a useful command. Thank you!
When I wanted to learn more, I read the entire nirsoft.net web site, which looks like a cornucopia of worthwhile software.
Then I looked into the Windows Task Scheduler taskschd.msc.
Lots of undesirable tasks with innocent sounding names are running all the time doing who knows what! One that caught my eye is MirageAgent, which apparently turns on my video camera and shares what it sees with anyone who asks. That one is going to get nullified right away. There are so many more tasks that it will take a month to stamp out all the cockroaches in that kitchen.
Thank you for this great article! One suggested correction: a more appropriate command may be
“nircmd.exe mutesysvolume 1” because this will mute the volume when the screen is locked, no matter what state the volume was in to begin with. The command you have recommended, “nircmd.exe mutesysvolume 2” will toggle the volume off or on, so this means that if the volume was muted at the time the screen was locked, then locking the screen will actually turn the volume on while you are away from your computer.
Gosh, how in the WORLD is this not a standard feature or easily-found and -configured option in Windows 10??! This post is golden, and so are you for posting it. Thank you!!!
Thanks for the information. I was hoping to find something here that would help with my issue. This would be very useful however I need my audio playing while locked as in my position I am not always at the PC but normally within earshot.
The issue is that the phone at my desk gets used for paging during system checks through out the plant. The Audio from my PC is not wanted and with WIN 7 it was very easy to just hit the mute button on the keyboard and it muted. However, the Media Controls do not work with WIN 10 when the system is locked.
Is there away to allow this? I am not always at my desk to log back in just so I can mute the audio for someone to page from my phone.
This is such a nice elegant solution. I agree with comment above that it should be built into Windows, but I am grateful for this excellent workaround. Thank you, Martin!!