Tuesday, December 26, 2006

Setting Windows Display Mode From The Command Line

A relative of mine runs Windows ME (yes Microsoft, people are still running 98/ME even though you discontinued support for it this year) and wanted to play an old version of Scrabble. One problem was that this version of Scrabble must be run in 256 color mode, but switching to 256 color mode can make other applications do strange things.

Instead of forcing the relative to manually switch to 256 color mode before running Scrabble and then manually switch back to True Color mode after exiting the game, a bit of Googling found a more automated solution: nircmd is a command-line utility that can do all sorts of Windows admin things that you would normally have to do through the GUI including setting display modes, create shortcuts, modify file properties, empty the recycling bin, mute the speaker, turn off the monitor, ejecting the CDROM and much more.

So I created a batch file that sets the display mode to 256 colors (8 bits) using nircmd and then launches Scrabble:

nircmd setdisplay 800 600 8
scrabble.exe

Just to be sure the display is restored to a better color mode I then created a startup script that sets the display back to True Color (24 bit).

I wish Microsoft would create such useful command-line admin utilities and ship them with the OS. (MS do make some command-line admin utilities, but they ship as optional extras and they are not very consistent across versions of Windows :()

nicrmd can also reboot a PC, so it might come in handy to do a remote reboot of a PC when Remote Desktop starts to play up (as it does if the PC hasn't been rebooted in the last few days) :)

No comments: