I just read this post (from Jeffery Hicks?): Make an old friend do your work where he explains how you can use good old doskey to make your life easier (at the command line), and it motivated me to write a blog entry for 2 reasons:
- he missed a few points
- I want to remember this stuff too, since it seems I'm starting to forget stuff =o(
Let's see, first of all he defines a macro like this:
doskey xl="%programfiles%\Microsoft Office\Office11\Excel.exe" $1 $2 $3 $4 $5
and explains "You can use variables like $1 and $2 (all the way up to $9)".
but why limit yourself to 9 parameters? you can write it as:
doskey xl="%programfiles%\Microsoft Office\Office11\Excel.exe" $*
that will take whatever number of parameters you pass to it. To test that it actually took more than 10 parameters I created a file 1.xls and then ran this command (a lot of people don't know this one):
for /l %e in (2,1,11) do copy 1.xls %e.xls
Which by the way means (loop from 2 to 11 in steps of 1, copy file 1.xls to [variable].xls);
now I had 11 files to play with, so I called my macro:
xl 1 2 3 4 5 6 7 8 9 10 11
which brings me to another point he missed: "from a command prompt I can type xl file1.xls file2.xls file3.xls and have Excel open all three files"
You don't have to specify the extension, you can just pass the file name-no extension and excel will open it happily
This also brings me to another point: if you just wanted to open a single file, you could just type the file name:
and Windows will open it in the default application (most likely excel) so for single files, we don't even need the macro
finally, this macro thing doesn't really work for notepad (or notepad2) if you call
np 1.txt 2.txt it tries to open the file "1.txt 2.txt"
you can only open single files =o(
one last tip, to delete a macro you just do