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:
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.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.