3 new NirCmd commands to control the sound volume on Windows 7/Vista/2008 from command-line

The new version of NirCmd provides 3 new commands to control the sound volume on Windows 7/Vista/2008:

  1. setdefaultsounddevice - Allows you the set the default sound device on Windows 7/Vista/2008, exactly like you can do it from this window:
    Set Default Sound Device

    Set Default Sound Device

    Example for using this command:
    NirCmd.exe setdefaultsounddevice "Line In"

  2. setsubunitvolumedb - Allows you the set the sound volume level of subunits of a sound device, as you can do in the following device properties window:
    Speakers Properties Window

    Speakers Properties Window

    As opposed to the above user interface of Windows, which allows you to set the volume level in percent scale, the command of NirCmd only allows you to set the volume level in decibel unit. So far, I couldn't locate the exact formula that Microsoft uses to convert the decibel values into %.
    Examples for using the setsubunitvolumedb command:
    setsubunitvolumedb "Speakers" "Line In" -12
    setsubunitvolumedb "Speakers" "Microphone" -20

  3. mutesubunitvolume - Allows you to mute/unmute the subunits of a sound device.
    Examples for using the mutesubunitvolume command:
    mutesubunitvolume "Speakers" "Line In" 0
    mutesubunitvolume "Speakers" "Microphone" 1

14 Responses to “3 new NirCmd commands to control the sound volume on Windows 7/Vista/2008 from command-line”

  1. Jonathan Kay Says:

    Nir, I've wanted to be able to do this for a long time without silly hacks and/or UI automation. This is *great*.
    Thank you very much.

  2. framing basement walls Says:

    To Nir, I really appreciate you posting this. I wanted to have this function since then. It is really nice if you are able to control and manage the volume of your devices separately. The additional features are interesting.

  3. joshtravolta Says:

    Wow, this looks really promising. So far I was not able to find a tool to simply switch between my playback devices in Win7.

    I will give it a try once I'm home today.
    Thanks for your work :D

    cheers from Berlin, Germany

  4. Mac Says:

    This is perfect for us who switch video sources to the TV via a batch file. thanks

  5. Daniel Ceregatti Says:

    How does one toggle the muting of the microphone in the "Recording" tab? When I use the sample command, the only thing that's muted is the microphone's level in the "Playback" tab. I've tried several combinations, but none work: For example:

    nircmd mutesubunitvolume "Microphone" "Microphone" 2

    Since "Microphone" is the name of the device as well as the slider, but these are under the "Recording" tab.

    This command doesn't error, but it also doesn't do anything.


  6. Kendall Starr Says:

    Daniel, in case you never got an answer:

    nircmd.exe mutesysvolume 2 microphone

    will toggle-mute the microphone. i had the reverse problem; i had already gotten the mic to mute, but had to come here to find out how to mute its playback. hopefully that helps you :)

  7. Juan Says:

    i tried to create a shortcut and disable microphone because we want to switch on/off the microphone to record peoples speech, and its not working, the mic stills recording. (windows 7 ultimate x64)

    nircmd.exe mutesubunitvolume "Microphone" 2

  8. woeffie Says:

    Will this also work for "Front" in case of 5.1 audio devices?
    Something in my computer sets the "front" volume to zero at every re-start...

  9. David Says:

    Having same problem. I have been able to get other nircmd commands to work, but not the mute microphone on an XP or Win 7 x64 computer. Both are have an 5.1 audio device and no matter what wording I try, it never takes.

  10. Casey Says:

    What I found for muting the mic on x64 Win 7 was that the PLAYBACK device associated with the mic has to be designated as the default device. Not that the target recording device does not need to be set as default. I made sure my mic recording device had a unique name. The following command works for me.

    nircmd.exe mutesysvolume 2 Realtek

  11. Dave H Says:

    I confirm what Casey is saying. x64 Win 7.

    default playback device has to match mic input. which sucks because i want to use my speakers and not my mic's monitor jack.

    i would love to see this work as intended.

  12. Leo Says:

    I am using Win 7 x64 home pro

    the following command work well in command prompt but not work when I run in SSH termianl which run in the same user, any reason for this?

    nircmdc speak text Hello

  13. Leo Says:

    I did try use both 32 & 64bit version of nircmdc, same result.

  14. NaX Says:

    Excellent - could you add a parameter to select the default communication device?

Leave a Reply