-4

The left speaker of my laptop is not working well so I need to decrease left speaker level to 0% every time I use it. But whenever I need to use headphone I have to reverse it to 100% for left headphone.

I am here to find a solution through CMD. where I can switch from 0% to 100% volume of my left speaker using a .bat file.

Is there any way to control

speaker >> speaker properties >> levels >> balance

using command prompt?

Note: I have win10 (64bit)

VBAbyMBA
  • 806
  • 2
  • 12
  • 30
  • 2
    Perhaps you should to use vbscript instead of batch, take a look at this [How to control Windows system volume using JScript or VBScript?](https://stackoverflow.com/questions/2216334/how-to-control-windows-system-volume-using-jscript-or-vbscript) – Hackoo Oct 21 '19 at 08:15
  • @Hackoo I ask for `cmd` because one can place a `batch file` on desktop. Every time he/she need to switch form 0% to 100% he/she will only have to run that batch file. – VBAbyMBA Oct 21 '19 at 08:31
  • 1
    @IbneAshiq you can place a VBScript on the desktop too. Just save the code in a .VBS file and you will be able to execute it by double-clicking it. – Étienne Laneville Oct 22 '19 at 15:26

1 Answers1

3

If you want to do it in batch script, just save this code below as Switch_Mute_Volume.bat

So, When you double click on this batch script the volume switch from Volume (no mute) to mute. and when you repeat this action another time the volume switch from mute to no mute

@echo off
Title Switch Mute Speaker Volume
(echo CreateObject("WScript.Shell"^).SendKeys chr(173^))>"%Temp%\%~n0.vbs"
cscript //NoLogo "%Temp%\%~n0.vbs"

And if you want just to do it only in vbscript : Just save this code below Switch_Mute_Volume.vbs

CreateObject("WScript.Shell").SendKeys chr(173)

Here is another method using a HTML Application HTA If you want to use a GUI : Just copy and paste this code below as Switch_Mute_Volume.hta

<html>
<head>
<HTA:APPLICATION 
APPLICATIONNAME="Volume + - ON/OFF" 
BORDER="THIN" 
BORDERSTYLE="NORMAL" 
ICON="SndVol.exe" 
INNERBORDER="NO" 
MAXIMIZEBUTTON="NO" 
MINIMIZEBUTTON="NO" 
SCROLL="NO" 
SELECTION="NO" 
SINGLEINSTANCE="YES"/>
<title>Switch Volume + - ON/OFF </title>
<script language="vbscript">
'************************************************************************************
Sub window_onload()
    CenterWindow 250,150
End Sub
'************************************************************************************
Sub Volume(Param)
    set oShell = CreateObject("WScript.Shell") 
    Select Case Param 
    Case "MAX"
        oShell.SendKeys "{" & chr(175) & " 50}" ' volume maximum 100%
    Case "MIN"
        oShell.SendKeys "{" & chr(174) & " 50}" 'volume minimum 0% 
    Case "UP"
        oShell.SendKeys "{" & chr(175) & " 10}" 'volume +20%
    Case "DOWN"
        oShell.SendKeys "{" & chr(174) & " 10}" 'volume +20%
    Case "MUTE"
        oShell.SendKeys chr(173) 'allows to mute / reset the sound (switch)
    End select
End Sub
'*************************************************************************************
Sub Volume(Param1,Param2,Param3)
    set oShell = CreateObject("WScript.Shell") 
    oShell.SendKeys Param1 & chr(Param2) & Param3
    '--------------------------- MEMO ----------------------------------
    'oShell.SendKeys "{" & chr(175) & " 50}" ' volume maximum 100%
    'oShell.SendKeys "{" & chr(174) & " 50}" 'volume minimum 0% 
    'oShell.SendKeys "{" & chr(175) & " 10}" 'volume +20%
    'oShell.SendKeys "{" & chr(174) & " 10}" 'volume +20%
    'oShell.SendKeys chr(173) 'allows to mute / reset the sound (switch)
End Sub
'*************************************************************************************
Sub CenterWindow(x,y)
    Dim iLeft,itop
    window.resizeTo x,y
    iLeft = window.screen.availWidth/2 - x/2
    itop = window.screen.availHeight/2 - y/2
    window.moveTo ileft,itop
End Sub
'************************************************************************************
</script>
</head>
<body>
<center>
<BUTTON onClick="Call Volume('{','175',' 50}')" style="background: Red; color: white;WIDTH: 85px; HEIGHT: 30px">Volume MAX</BUTTON>&nbsp;&nbsp;
<BUTTON onClick="Call Volume('{','174',' 50}')" style="background: Blue; color: white;WIDTH: 85px; HEIGHT: 30px">Volume MIN</BUTTON>&nbsp;&nbsp;
<BUTTON onClick="Call Volume('{','175',' 10}')" style="background: Green; color: white;WIDTH: 85px; HEIGHT: 30px">Volume +20%</BUTTON>&nbsp;&nbsp;
<BUTTON onClick="Call Volume('{','174',' 10}')" style="background: Orange; color: white;WIDTH: 85px; HEIGHT: 30px">Volume -20%</BUTTON>&nbsp;&nbsp;
<BUTTON onClick="Call Volume('','173','')" style="background: DarkOrange; color: white;WIDTH: 85px; HEIGHT: 30px">ON/OFF</BUTTON>&nbsp;&nbsp;
</center>
</body>
</html>

Here a screenshot of this HTA :

enter image description here

Hackoo
  • 18,337
  • 3
  • 40
  • 70
  • As mentioned in the question. Only left speaker volume need to be change. Your answer is about switch between mute volume. – VBAbyMBA Oct 22 '19 at 15:38
  • @IbneAshiq So in this case if you found an answer to your issue, just let me know. Good Luck ! – Hackoo Oct 22 '19 at 15:40