What I need

I'm looking for a tool or a script that allows me to access the Windows volume levels from the command line. Ideally it would allow me to get and set all volumes including application levels, but I'd settle for only getting, and only the master level. I don't mind if it uses PowerShell, WMI, JavaScript, .Net, Voodoo, or butterflies. Any solution that will just give me a number that I can further process to fit a range from 0% to 100% will do.

Put another way, the prompt parts are the black box that I need filled:

C:\> getvol master

or even

C:\> wmic <alias> where "device='master' and name='volume'" get name,value
Name    Value
Volume  0xDEADBEEF

I don't mind if I have to spend some time to wrap it or even write something myself if the tools to do so are freely available. In the latter case, I'd need some pointers/proof-of-concept for the core, but I can manage the cruft on my own. Also I'd like to avoid installing new development frameworks just for this purpose (note that both music2myear's and iglvzx's answers were given before I introduced these requirements).

As "platforms", I have available:

  • anything that comes with Windows 7 Home Premium
  • anything that comes with Cygwin
  • Perl
  • Python
  • Ruby

Generally, open-source solutions are greatly preferred. Closed-source tools are ok as long as they're freeware and the source can be trusted. Commercial solutions are no-go.

What I don't need

  • There are a few similar questions that mostly deal with setting the volume. Most of all, I need to get the volume, not set.
  • There is nircmdc, which supports setting volume, but not getting.
  • There is a key[1] in my registry that has values that change predictably when I adjust the volume via the GUI mixer, but I'd guess reading from that key is prone to breakage on hardware changes or system upgrades. Unless I can rely on the solution being reasonably future-proof, I can't use it.
  • There are AutoHotKey and WSH solutions for setting the volume on the Web, but a) they too are only good for setting and, worse, b) they use SendKeys or automated mouse movement to control the GUI. Automating the GUI is not an option.

The ##windows channel on freenode is unhelpful as ever, Google overflows with hacks and half-baked workarounds, and I can't tell a WinAPI call from a Wiccan incantation.

Does anyone know of a way?

  1. HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E96C-E325-11CE-BFC1-08002BE10318}\0000\MixerSettings\eLineOutTopo\PrimaryNode000
  • Semms like WMI is not an option :( – Der Hochstapler Feb 28 '12 at 14:59
  • Possibly relevant: superuser.com/questions/284527/… – Der Hochstapler Feb 28 '12 at 15:01
  • Do you need me to expand my answer? I wasn't sure of you needed more, since you seem to have experience with programming. I can provide an example on how you can use AutoHotkey to easily achieve your goal. – iglvzx Mar 1 '12 at 22:37
  • I think it's a very good suggestion, thanks again, but AHK bit me once and I'm shy ever since. I probably wouldn't use it even if it was a fully fledged-out solution. Nothing keeping you from expanding on it for future readers/more upvotes though. :) – peth Mar 1 '12 at 23:12
  • 1
    (as a note that reg. doesn't even seem to exist on my box, so...it may be unstable indeed). See also my c++ answer here: stackoverflow.com/a/21056089/32453 – rogerdpack Jan 10 '14 at 23:05

This question was asked and answered on StackOverflow: https://stackoverflow.com/questions/4640106/how-to-get-current-volume-of-system-sound-device-in-windows-7

The answer: https://stackoverflow.com/a/4640225/704977

You're looking for the EndpointVolume API. This is part of the new audio APIs that were released in Windows Vista, and it can be used to get or set the master volume.
... There's a complete managed wrapper library available on CodeProject: Vista Core Audio API Master Volume Control.


I know you said you did not want an AutoHotkey solution, but I believe the AutoHotkey API has what you are looking for:

You do not need to create GUIs or use hotkeys with AutoHotkey. You can write powerful command line utilities by compiling an .ahk script. That being said, you will want to look at the FileAppend command for working with stdout.

  • here's one that does it: gist.github.com/rdp/8363141 (though a straight console app for it may be simpler/easier, see other comments here) – rogerdpack Jan 13 '14 at 17:33

The master volume is stored in the registry location:


For example, this REG file sets the master volume to 100%.

Windows Registry Editor Version 5.00


The key name may differ. You need to restart for changes to take effect.

You may not be able to edit or open the Properties or {7fb7b48f-531d-44a2-bcb3-5ad5a134b3dc} key in regedit. Although you have the necessary access permissions, you may receive an error like this:

[Window Title]
Error Opening Key

{7fb7b48f-531d-44a2-bcb3-5ad5a134b3dc} cannot be opened.
An error is preventing this key from being opened.


This is because the key name is too long. You will have to temporarily rename the long key name to one character and then rename it back.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.