Tuesday, August 14, 2012

Assigning a default handler to extensionless files in Windows

I recently ran into a large number of files that have no extension. My attempt at batch processing this files was hindered. In Microsoft Windows, if you double click on a file that has no extension, the "Open With" dialog will appear and ask you which program to use to open the file.

Normally, you could choose the program and then check the box "Always use the selected program to open this kind of file" and then the file open process would be automated going forward. When the file has no extension, that box is greyed out, so the automated file opening by a certain program cannot happen.

To fix this (to cause a file without an extension to open in Notepad.exe by default) I looked into the registry.

The registry key Computer\HKEY_CLASSES_ROOT\.txt contains the instructions for the ".txt" extension.

".txt" (Key)
---- (Default) = "txtfile" - (String)
---- Content Type = "text/plain" - (String)
---- PerceivedType = "text" - (String)
---- PersistentHandler (Key)
-------- (Default) = "{5e941d80-bf96-11cd-b579-08002b30bfeb}" - (String)
---- ShellNew (Key)
-------- etc...

What I did was copy the strings and the PersistentHandler registry key into a new sibling without the "txt" portion.

" ." (Key)
---- (Default) = "txtfile" - (String)

---- Content Type = "text/plain" - (String)
---- PerceivedType = "text" - (String)
---- PersistentHandler (Key)
-------- (Default) = "{5e941d80-bf96-11cd-b579-08002b30bfeb}" - (String)

The logic behind this is that ".txt" opens ".txt" files with a certain handler and treats them a certain way. A file without an extension is effectively just "." instead of ".txt."

To my surprise, it works. Any file without an extension is automatically opened in Notepad.exe.

Monday, August 13, 2012

WRT54G - The ubiquitous.

I've had a few WRT54G routers over the years and they've been really great. Major kudos to Linksys (and secondarily Cisco) for making a great product and supporting it for so long.

I recently upgraded one of my WRT54Gs to firmware 4.21.5 (Feb 2012). It was running perfect, so I suppose that upgrading was a stupid gesture. My router is a version 2.0 (#3 of 12 versions). The router is old and I should have known.

Well all of the wireless devices started to drop connection on a regular basis since I upgraded the firmware.

Turns out, it is really hard to find a source for the old firmware bin files.

So I turned to DD-WRT, which I had used in the past, but since I prefer to use the OEM firmware (if possible) I had reverted to a newer, working version of the Linksys firmware.

DD-WRT is a free, opensource firmware for the WRT54G (and many other) routers. It is a beautiful thing to not have to throw away a $50 piece of hardware because the manufacturer's firmware turned it into a useless piece of junk.

Updating to DD-WRT
Some tips you may find useful:

Use the latest version recommended on the DD-WRT router database, NOT a version you downloaded from somewhere else (it might be old).

Use a wired connection for the upgrade. You do not want to get frustrated with settings, trying to connect, not knowing what the default SSID is, etc.... just plug it in first and you'll be better off.

You can backup your settings, but considering this is a new firmware, you should start from scratch. Settings are easy to get back if you know what they are.
1. Write down your settings (DHCP settings, wireless security type, key, encryption, channel, etc)

If you upgrade from the Linksys firmware to DD-WRT for the first time, you may need to reset the router to factory conditions.
1. Unplug it
2. Hold down the reset button and plug it back in
3. Keep it pressed for about 20 seconds

When it comes back, remember that the default IP address is 192.168.1.1, NOT whatever you had it set at.

The DD-WRT default username is "root" and the default password is "admin" for versions 23 SP1 and greater.

Last tip. Have an alternate means of connecting to the internet in case you forget everything and need to search for help. A smartphone will do.