2

Using nircmd we can set system volume level(audio) but how to get system volume?

How can we get system volume using powershell?

1 Answers1

0

How to get system volume?

You can also use NirCmd for for this:

@echo off
setlocal enabledelayedexpansion
SoundVolumeView.exe /GetPercent Speaker/HP
set /a _volume=%errorlevel% / 10
echo %_volume%%%
endlocal

where Speaker/HP is the name of my audio device.


Get sound level information from command line

Use the get commands of SoundVolumeView - /GetPercent, /GetPercentChannel, /GetDecibel, /GetDecibelChannel, /GetMute :

These commands return the desired sound level information inside the Exit Status of the program. Because the Exit Status is an integer value, the percent value is multiplied by 10 and the Decibel value is multiplied by 1000. You can get more information about these commands in the 'Command-Line Options' section.

You can get the desired value inside a batch file by using the %errorlevel% variable, for example.

SoundVolumeView.exe /GetPercent Speakers
echo %errorlevel%

Be aware that the above example only works when saving the commands into a batch file and then running the batch file. If you try to execute it without a batch file, you'll only get zero result. It's not a bug in SoundVolumeView, it's just the way that the %errorlevel% variable works.

Source: View / change sound volume on Windows from command line or GUI

DavidPostill
  • 162,382