I'm helping a user with a personal Windows 11 computer which, in addition to the built-in monitor, is connected via HDMI to a shared/public television display.
When it comes time to stream a show or movie to the larger display, the following two operations must occur:
Then, when steaming time is over, the Sound and Display settings must be set back to the more private configuration:
This "works" in that it produces the desired outcome, but is not "workable" for the non-technical user, given the number of touch points and values to remember. What would be great would be a pair of functionally equivalent scripts (one for each workflow) that I could link to as Desktop shortcuts.
Assuming full administrator access, is such a thing possible? Is there any API documentation I should be searching?
For display devices, Windows comes with a built-in command-line program displayswitch.exe
(though do note that Windows 10 and Windows 11 have different, and incompatible, command-line options).
For audio output, Windows doesn't seem to have a built-in command-line program nor PowerShell cmdlet, but NirSoft provides a reputable command-line program: nircmd setdefaultsounddevice
.
So combine the two:
Start Streaming.cmd
REM For Windows 11:
REM DisplaySwitch.exe 1 = Internal
REM DisplaySwitch.exe 2 = Clone
REM DisplaySwitch.exe 3 = Extend
REM DisplaySwitch.exe 4 = External
DisplaySwitch.exe 3
nircmd setdefaultsounddevice "Desired output device name" 1
Stop Streaming.cmd
DisplaySwitch.exe 1
nircmd setdefaultsounddevice "Desired original output device name" 1