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?

Cameron
  • 185
  • 3
  • 9
  • 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 '15 at 16:32
  • I need to know what the current volume of the system is. – Cameron Jun 29 '15 at 16:32
  • Yes, but why? what is the ultimate goal? – LPChip Jun 29 '15 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](https://msdn.microsoft.com/en-us/library/ms713762(VS.85).aspx) and [waveOutGetVolume](https://msdn.microsoft.com/en-us/library/aa909806.aspx). With some very basic knowledge of C++ you can achieve what you want – Art Gertner Jun 29 '15 at 16:33
  • On the other hand, if the only reason why you want to know the current volume level is to be able to increment it by a fixed value, then you can achieve the same with [Autohotkey](http://www.autohotkey.com/). FYI: http://superuser.com/q/82229/281154 – Art Gertner Jun 29 '15 at 16:36
  • 1
    I need to know it so that I can show the current volume in the UI. – Cameron Jun 29 '15 at 16:41

1 Answers1

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

jgstew
  • 53
  • 7