Make sure the VS install location is a part of your path.  For example, “program files\microsoft visual Studio 8\common7\IDE” should be in your path environment variable.  Then, it’s just

Devenv.exe foo.txt

Note this will open the file using the file window layouts, which is one of the four types of window layouts we save (file, design, full screen, and debugging).

Also note that this will open the file in a new instance of the shell.  If you want VS to open the file in an existing instance, download the VSEdit Powertoy.

Happy Visual Studio’ing!