Some Bits: Nelson's log

Scripting Windows sound and display settings

I have my TV plugged in via HDMI to my Windows machine for occasional gaming. When I want to play games I need to swap the display resolution to one for the TV and also change the sound output device to the HDMI device. I’ve got it set for display mirroring; gaming as a second display sorta works but gets confusing and can require trips back to the mouse and keyboard.

Anyway I got tired of doing it by hand so I scripted it. The key is Nirsoft’s program NirCmd. It gives you a command line interface for doing all sorts of Windows desktop and system manipulations. Here’s the batch file I use to get into desktop mode:

nircmd.exe setdisplay 3440 1440 32
nircmd.exe setdefaultsounddevice Speakers

There’s both a nircmd and a nircmdc. The former pops up a window for error messages, the latter shows them on the console.