Sunday, February 26, 2006

New utility: PathFind.exe

When I recently encountered the issue where an old version of ildasm.exe instead of the latest version was unexpectedly used when run from the command line, due to the folder of the older version being located in my machine's PATH first, I thought of the which utility for unix/linux, which returns the location of a file on the path. (The "path" in this context is the set of folders that the operating system will search for a program that the user has requested to run from the command prompt or Windows' Start | Run dialog.) The "which" utility would have allowed me to immediately verify that the copy of ildasm.exe that was being run was not located in the expected directory.

I wasn't aware of a similar command-line utility for Windows, and writing one seemed like a simple enough matter, so I decided to write one. The utility would just need to get the value of the PATH environment variable, parse the individual directories out of the path, then do a "file exists" check in each PATH folder, checking for the specified file name.

I was able to put the program together fairly quickly, and it seemed like something that people might find to be generally useful, so I spent a little bit more time to polish it, then added it to the utilities page on my homepage for download as PathFind.exe. The extra polish included automatic searching for the file with extensions from the PATHEXT environment variable (.com, .exe, .bat, and so on) for files for which no extension is specified (so the user can search for just "iisreset" instead of having to search for "iisreset.exe"), as well as things like input validation, error handling, and a help message.

As it turns out, Microsoft also has released a similar utility, where.exe, available for download with some of its resource kits and SDKs such as the Windows 2003 SP1 Platform SDK (but not apparently available as a stand-alone download). The where.exe utility supports wildcard searches and some other advanced options, but doesn't support automatic PATHEXT extension searching.

Friday, February 24, 2006

Fix: "Failed to open meta data" in ildasm.exe

This issue is pretty easy to come up with a fix for using a Google search, but I thought I'd note it here anyway.

If you get the error message "error : Failed to open meta data" when trying to open a file with ildasm.exe (Microsoft's .Net intermediate language (IL) disassembler), check to make sure that the ildasm version you are using matches the .Net version that the target file was built with. I encountered this problem when I was trying to run ildasm from the command line targetting a .Net 2.0 assembly, but the first instance of ildasm.exe on my path was the 1.1 version.

Thursday, February 23, 2006

The true utility of Google Talk / Gmail integration

Google recently integrated Google Talk (their IM client) with Gmail (their email service). (More info on this is available in this Official Google Blog Post). Now, when you open a browser window with your Gmail inbox, a Google Talk widget with your "buddy list" appears in the window. You can also chat directly in the Gmail browser window in "popup panes" that appear in that window.

At first, I wasn't sure about the utility of this new feature. The thing that made Google itself take off at first a few years back, aside from the generally excellent quality of their search results, is the fact that the search page presented a really clean interface -- the Google logo, a text field, a "Search" button, and not much else. This integration of Google Talk into the Gmail window makes the Gmail interface seem rather more cluttered. I'm happy to just use the separate Google Talk desktop app.

However, the Google Talk / Gmail integration has enabled me to do something I've haven't been able to do before -- chat with my wife Missy at work!

Missy works at a large corporation where all individual workstations are heavily locked down security-wise. Users cannot install new software of any kind without IT intervention, and most ports on the external firewall are closed, so Missy has never been able to get any IM application to work on her work machine, including the Google Talk desktop app.

However, at least so far, the Google Talk client integrated into the Gmail browser window works just fine! It's in the browser window so there's nothing to copy onto the local machine, and whatever port the app is using to communicate is apparently not blocked.

So the Gmail-integrated Google Talk has at least allowed Missy and I to chat via IM during the day, which is pretty cool. Even though email and phone were both available to us before, IM just provides another way for us to stay in touch while we're apart, which is a good thing! :-)

Monday, February 20, 2006

Why I still use Notepad.exe

A reasonable response after reading my previous post about a Notepad.exe bug might be "So what? Just use a *real* text editor." However, despite its shortcomings, for simple text-editing tasks, I still use Notepad a lot. Some reasons for this are:

(1) It's lightweight and doesn't have features that I don't want. (Examples are Word's autoformatting of things like bullet points and emoticons.)

(2) It supports the basic set of text-editing shortcut keys that work in other common Microsoft apps like Word and Visual Studio. (For example, Ctrl+F = Find, Ctrl+H = Find and Replace.)

(3) It doesn't do anything unnecessary with the clipboard -- it both copies and pastes pure text only, without any formatting. (One method for stripping formatting from text on the clipboard is to Paste it into a Notepad window and then Copy the pasted text from Notepad.)

(4) I can jump to a specific line number (with Ctrl+G).

(5) Perhaps most importantly, it's on every Windows machine that I sit down at.

I'd like to use a more powerful text editor like vi or Emacs, but I think once I got used to those editors, I'd be too annoyed every time I sat down at someone else's machine (which I do with reasonable frequency) because the editor wouldn't be present, and my habitual keyboard shortcuts wouldn't be available. (I might access the editor from my own machine over the network or carry it around on a USB drive, but that's also annoying.)

I also haven't found a "Notepad Plus" application that I really like enough to make a point of using it instead of Notepad. I'm trying out Notepad2 currently, but there a couple of things I don't like about it, such as the "Recent Files" section of the File menu not being implemented in a standard way, and Alt+N not working to jump to the text field in the Find dialog (which I've found that I actually use a lot).

The feature that standard Notepad does not have which I most wish it did have is a "Reopen" feature. Oftentimes I have some log file open and I want to see the most recent version on the hard drive that has been updated with recent logged events, but to do this with Notepad I have to do through the File | Open dialog and retype or reclick the name of the current file, which is a hassle.

It would be really nice if some developer at Microsoft would ask for a week or two of development time to really "fix" notepad -- add the Reopen feature and some other basic features that most other modern text editors have, such as "smart tabbing" (selecting one or more entire lines of text and pressing Tab or Shift+Tab indents/unindents the text instead of replacing it with a tab character). They could package the updated Notepad with Vista as another reason for people to upgrade!

I hope the reason that Microsoft *hasn't* done this isn't something silly like they are concerned that it could adversely affect MS Word sales.

Notepad.exe bug

(1) Open a new instance of Notepad.exe (Start | Run | notepad). Turn on Word Wrap (from the Format menu) if it isn't enabled already.

(2) Type some text that includes spaces, enough that the text wraps onto a few lines. (Try typing "The quick brown fox jumped over the lazy dog. " and then copy and paste that same text into the window another few times.) At this point, the caret (insertion point) should be at the end of the text.

(3) Save the document (from the File menu, or just push Ctrl+S). After the save is finished, notice the position of the caret -- it has backed up a few spaces!

This seems to happen whenever you save after typing a new line of text that needed to wrap. I can reproduce this on both Windows XP and Windows 2003 Server machines. If I recall correctly, the bug exists on older Windows versions as well.

A very minor bug, but Notepad is a pretty simple and heavily-used application. I'm surprised that no one at Microsoft has taken a few minutes to fix it!