Need to be spoonfed a basic batch script to change system audio


paradoxum

Sublimed
Member
Local time
8:13 AM
Posts
148
OS
Windows 11 [22H2] [22621.2428]
Not sure where to post help for things like this, it's kind of a customization thing but I didn't think it'd fit there..

Anyway I have an alternative boot sound I use, but the boot sound uses windows system audio in the mixer, which I normally have at '1', because the slider for it has been uneven for years and anything higher is way too loud (not just me right?).

Anyway I'd like a script that I can add to task scheduler or something that will set the windows system volume to 50%, and then after 10 seconds set it to 1%, then I will have scheduler run it every hour after the first run, and if possible I'd like it to keep setting the system volume to 1% across all output devices then, because, I'm not sure what it is it could be anything from plugging my headset dongle into a different USB port, but my system volume is constantly being reset to 100% and I'm greeted with the loud DADUNNGGGG noise when there's a windows error popup.

I tried to get started myself and I won't even go into the actual script cause things I pulled from stackexchange and tried editing nothing worked, but I found this tool SoundVolumeView and it has extensive command line args;

I've been just trying things like
>
:: Mute/Unmute
svcl.exe /SetVolume "System Sounds" 75
Etc.

And a little mockup of what I'm looking for;
:: Mute/Unmute
svcl.exe /GetMute "Headphones"
if muted
svcl.exe /Unmute "Headphones"
svcl.exe /SetVolume "System Sounds" 50
wait 5s
svcl.exe /SetVolume "System Sounds" 1
every 60min repeat line 7
 
Windows Build/Version
22631.2715

My Computer

System One

  • OS
    Windows 11 [22H2] [22621.2428]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Culture-Virus v4.0
    CPU
    i7-11700k
    Motherboard
    ASUS ROG Strix Z590
    Memory
    32GB Crucial Ballistix 3600MHz @ 4227MHz 16-18-38 2T
    Graphics Card(s)
    AMD Radeon RX 6900 XT
    Monitor(s) Displays
    AOC CQ27G2U/BK
    Screen Resolution
    2560x1440
    Hard Drives
    M.2 1: Samsung SSD 990 PRO 2TB
    M.2 2: Samsung SSD 970 EVO Plus 2TB
    PSU
    Corsair RM1000X SHIFT
    Case
    Fractal Design 7 XL
    Cooling
    Custom Water
    Keyboard
    Corsair K70 RGB TKL CHAMPION SERIES
    Mouse
    ROCCAT LEADR Optical
    Browser
    Chrome
Forgot to say thanks if anyone can help. I really struggle with cmd line stuff and things like regex etc. (I know this has no regex but it often comes with making batch files.)
 

My Computer

System One

  • OS
    Windows 11 [22H2] [22621.2428]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Culture-Virus v4.0
    CPU
    i7-11700k
    Motherboard
    ASUS ROG Strix Z590
    Memory
    32GB Crucial Ballistix 3600MHz @ 4227MHz 16-18-38 2T
    Graphics Card(s)
    AMD Radeon RX 6900 XT
    Monitor(s) Displays
    AOC CQ27G2U/BK
    Screen Resolution
    2560x1440
    Hard Drives
    M.2 1: Samsung SSD 990 PRO 2TB
    M.2 2: Samsung SSD 970 EVO Plus 2TB
    PSU
    Corsair RM1000X SHIFT
    Case
    Fractal Design 7 XL
    Cooling
    Custom Water
    Keyboard
    Corsair K70 RGB TKL CHAMPION SERIES
    Mouse
    ROCCAT LEADR Optical
    Browser
    Chrome
Code:
:begin
set isMuted=svcl.exe /GetMute "Headphones"
if %isMuted% equ 1 goto muted
:muted
svcl.exe /Unmute "Headphones"
svcl.exe /SetVolume "System Sounds" 50
timeout /t 5 /nobreak
svcl.exe /SetVolume "System Sounds" 1
timeout /t 3600 /nobreak
goto begin

I haven't written a batch file in years but the above should work? Otherwise it might be better to write it using PowerShell instead.
 

My Computer

System One

  • OS
    Windows 11, Windows 10, Linux Fedora Cinnamon
Haven't done this personally but maybe this will help? I think @x BlueRobot probably has it correct.
 

My Computer

System One

  • OS
    Windows XP/7/8/8.1/10/11, Linux, Android, FreeBSD Unix
    Computer type
    Laptop
    Manufacturer/Model
    Dell XPS 15 9570
    CPU
    Intel® Core™ i7-8750H 8th Gen Processor 2.2Ghz up to 4.1Ghz
    Motherboard
    Dell XPS 15 9570
    Memory
    32GB using 2x16GB modules
    Graphics Card(s)
    Intel UHD 630 & NVIDIA GeForce GTX 1050 Ti with 4GB DDR5
    Sound Card
    Realtek ALC3266-CG
    Monitor(s) Displays
    15.6" 4K Touch UltraHD 3840x2160 made by Sharp
    Screen Resolution
    3840x2160
    Hard Drives
    Toshiba KXG60ZNV1T02 NVMe 1024GB/1TB SSD
    PSU
    Dell XPS 15 9570
    Case
    Dell XPS 15 9570
    Cooling
    Stock
    Keyboard
    Stock
    Mouse
    SwitftPoint ProPoint
    Internet Speed
    Comcast/XFinity 1.44Gbps/42.5Mbps
    Browser
    Microsoft EDGE (Chromium based) & Google Chrome
    Antivirus
    Windows Defender that came with Windows
 

My Computer

System One

  • OS
    Windows 11 Pro
I haven't tested this myself yet but this should work?

Code:
# Executable File Path
$exe = "svcl.exe"

# Sound Sources
$headPhones = "Headphones"
$speakers = "System Sounds"

# Checks if the sound source is muted
function IsMuted {
    [Parameter(Mandatory=$true)]
    param([string]$soundSource)
    Start-Process -FilePath $exe -ArgumentList "/GetMute $soundSource"
}

# Unmutes the specified sound source
function Unmute {
    [Parameter(Mandatory=$true)]
    param([string]$soundSource)
    Start-Process -FilePath $exe -ArgumentList "/Unmute $soundSource"
}

# Sets the volume of the specified sound source to the desired level
function Set-Volume {
    [Parameter(Mandatory=$true)]
    param([string]$soundSource, [int]$level)
    Start-Process -FilePath $exe -ArgumentList "/SetVolume $soundSource $level"
}

# Sets the script to "sleep" for the desired timeout period
function SleepScript {
    [Parameter(Mandatory=$true)]
    param([int]$period)
    Start-Sleep -Seconds $period
}

while (true) {
    $isMuted = IsMuted -soundSource $headPhones
    if ($isMuted) {
        Unmute -soundSource $headPhones
        Set-Volume -soundSource $speakers -level 50
        SleepScript -period 5
        Set-Volume -soundSource $speakers -level 1
        SleepScript -period 3600
    }
}
 

Attachments

  • sound.ps1
    1.3 KB · Views: 2

My Computer

System One

  • OS
    Windows 11, Windows 10, Linux Fedora Cinnamon
Sorry for some reaon I wasn;'t getting email replies so I thought noboby replied. Will get back to this in a bit going to to walk dogs thank you.
 

My Computer

System One

  • OS
    Windows 11 [22H2] [22621.2428]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Culture-Virus v4.0
    CPU
    i7-11700k
    Motherboard
    ASUS ROG Strix Z590
    Memory
    32GB Crucial Ballistix 3600MHz @ 4227MHz 16-18-38 2T
    Graphics Card(s)
    AMD Radeon RX 6900 XT
    Monitor(s) Displays
    AOC CQ27G2U/BK
    Screen Resolution
    2560x1440
    Hard Drives
    M.2 1: Samsung SSD 990 PRO 2TB
    M.2 2: Samsung SSD 970 EVO Plus 2TB
    PSU
    Corsair RM1000X SHIFT
    Case
    Fractal Design 7 XL
    Cooling
    Custom Water
    Keyboard
    Corsair K70 RGB TKL CHAMPION SERIES
    Mouse
    ROCCAT LEADR Optical
    Browser
    Chrome

Latest Support Threads

Back
Top Bottom