Forum Discussion
Media Keys and Teams notifications
- Dec 28, 2020Hi graemec5
Known issue, as raised here on uservoice
https://microsoftteams.uservoice.com/forums/555103-public/suggestions/39956326-media-keys-affecting-teams-web-app
If you go to that uservoice, a few comments down you should see a solution to this: go to avatar > settings > permissions > turn off midi device. People have reported that it has solved it for them
Hope this resolves and answers your question
Best, Chris
I had some fun automating the process of changing the Teams executable. First iterations took about 10 to 15 minutes to complete but this one does the job in about 5 seconds. You don't have to use it if you don't trust it but it sets the original EXE aside so if something wrong happens, you can just replace the resulting file from this script with the original
# Getting the filepath for Teams.exe
$FilePath = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Microsoft\Teams\current\Teams.exe"
# Killing all instances of Teams.exe
Get-Process | ? { $_.Path -eq $FilePath} | Stop-Process -Force -Confirm:$False
# Get the Hex and Binary format of the option "HardwareMediaKeyHandling"
$Option = "HardwareMediaKeyHandling"
$HWMKeyHandlingHexArray = ($Option.ToCharArray() | % { [String]::Format("{0:X2}", [System.Convert]::ToUInt32($_)) }) -Join "-"
$HWMKeyHandlingByteArray = [Byte[]]($HWMKeyHandlingHexArray.split("-") | % { "0x{0}" -f $_ })
# Other needed variables
$ValueOffset = 8
$OldValue = 1
$NewValue = 0
# Get Teams as ByteArray and Hex String
$Bytes = [System.IO.File]::ReadAllBytes($FilePath);
$Hex = [System.BitConverter]::ToString($Bytes)
# Get the location of the option in de HexString
$HexIndex = $Hex.IndexOf($HWMKeyHandlingHexArray)
# Calculate the index of the hex to the index of the byte array
# Account for the dashes in the string
$Index = $HexIndex * 2 / 3
# Account for the fact that HEX makes couples of 2 characters for a byte
$Index = $Index / 2
# Build in some safety
$GotIt = $True
For ($i = 0 ; $i -lt $HWMKeyHandlingByteArray.Count ; $i++) {
If ($Bytes[($Index + $i)] -ne $HWMKeyHandlingByteArray[$i]) {
$GotIt = $False
}
}
If ($GotIt -eq $False) {
"Something went wrong calculating the exact location of '{0}'" -f $Option
Break
}
Else {
# Checking for the value of the option
$ValueIndex = $Index + $HWMKeyHandlingByteArray.count + $ValueOffset
If ($Bytes[$ValueIndex] -eq $OldValue) {
# Actually setting the value
"Changing the value of option '{0}' from {1} to {2}" -f $Option, $OldValue, $NewValue
$Bytes[$ValueIndex] = $NewValue
# Set aside the old file for if something went wrong despite the checks in this script
$File = Get-Item -Path $FilePath
$CopyFilePath = Join-Path -Path $File.DirectoryName -ChildPath ("{0}.old{1}" -f $File.BaseName,$File.Extension)
[Void](Copy-Item -Path $FilePath -Destination $CopyFilePath -Force:$False -Confirm:$False)
# Write new teams.exe
[System.IO.File]::WriteAllBytes($FilePath, $Bytes)
}
ElseIf ($Bytes[$ValueIndex] -eq $NewValue) {
"No need to update the value: '{0}' is already set to {1}" -f $Option, $NewValue
}
Else {
"Something isn't correct, the value for option '{0}' is neither {1} or {2} but {3}" -f $Option, $OldValue, $NewValue, $Bytes[$ValueIndex]
}
}
This HEX editing method is the only workable one I've found. It does **bleep** up the Digital Signature so it could get flagged by some EDRs but nothing yet from FortiEDR here.
Hofa Your script gives me this result:
Something isn't correct, the value for option 'HardwareMediaKeyHandling' is neither 1 or 0 but 72
- HofaNov 23, 2022Copper Contributor
OudstandCan you add this in the last Else clause, run the script again and report back with the output?:
[System.BitConverter]::ToString(($Bytes[$ValueIndex..($HWMKeyHandlingByteArray.count + $ValueOffset + 10)]))
- OudstandNov 23, 2022Copper Contributor
Hofa the output is longer than the console can display it. I could post the code which is still shown in the console window. Do you want me to do this?
- HofaNov 23, 2022Copper Contributor
Oh my bad. Updated:
[System.BitConverter]::ToString(($Bytes[$ValueIndex..($ValueIndex + $HWMKeyHandlingByteArray.count + $ValueOffset + 10)]))