Wednesday, September 10, 2014

PowerShell - Change / Mute Audio Volume

Volume Mute Button
$obj = new-object -com wscript.shell
$obj.SendKeys([char]173)

Volume Down Button
$obj = new-object -com wscript.shell
$obj.SendKeys([char]174)

Volume Up Button
$obj = new-object -com wscript.shell
$obj.SendKeys([char]175)

** Each volume counter = 2%
Ex: Set Volume to 50%
Function Set-Speaker($Volume){ $ws = new-object -com wscript.shell;1..50 | % { $ws.SendKeys([char]174)};1..$Volume | % { $ws.SendKeys([char]175) } }
Set-Speaker(25)

1 comment: