3

I'm using the NirCmd utility to set the audio volume via the command prompt for a game but need to know what the current volume is upon the app start up.

I found this question: Change Windows sound volume via the command line which also mentions NirCmd but doesn't mention how to use it to get the current volume.

I've tried getvol master, but I get the error getvol is not recognized.

How can I get the current audio volume either using native Windows commands or NirCmd?

6
  • That is not possible. What are you trying to accomplish? If you want to increase or decrease the volume, just use nircmd.exe changesysvolume 2000 and nircmd.exe changesysvolume -2000.
    – LPChip
    Jun 29, 2015 at 16:32
  • I need to know what the current volume of the system is.
    – Cameron
    Jun 29, 2015 at 16:32
  • Yes, but why? what is the ultimate goal?
    – LPChip
    Jun 29, 2015 at 16:33
  • Neither NirCmd nor any of existing Windows built-in tools can get the volume value in command prompt. NirCmd can only set the volume. You might want to look for another third-party solution or write one yourself. Try looking at waveOutSetVolume and waveOutGetVolume. With some very basic knowledge of C++ you can achieve what you want Jun 29, 2015 at 16:33
  • 1
    I need to know it so that I can show the current volume in the UI.
    – Cameron
    Jun 29, 2015 at 16:41

1 Answer 1

4

Ideally you would use the same .Net or Win API that tools like NirCmd are using to do this directly.

I have also been struggling to find a good and simple command line option to get the current system volume.

I finally found something that works on Windows 10.

I haven't tried older versions of windows yet, but I presume it works for Windows Vista or later.

It is available here: https://sourceforge.net/projects/mplayer-edl/files/adjust_get_current_system_volume_vista_plus.exe/download

Usage:

adjust_get_current_system_volume_vista_plus.exe

returns the current volume and exits

adjust_get_current_system_volume_vista_plus.exe 50

sets the volume to 50 then returns the current volume (50) and exits.


There is also a python option here: https://github.com/AndreMiras/pycaw


It should be possible to do this with PowerShell as well: https://stackoverflow.com/a/19348221/861745

2
  • 1
    +1 for the Python option. Nov 19, 2021 at 23:13
  • 1
    Worth noting that you cannot use adjust_get_current_system_volume_vista_plus.exe to identify if Windows is muted.
    – Richard
    Dec 26, 2022 at 13:17

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.