Dave said:
Hmm, I wonder if their batch commands might not need a fix. The dir
command might not work if there are spaces in the directory name. Is
the %1 parameter guaranteed to be the 8.3 name, or might it be the long
name? If a long name, then the batch file needs to put quotes around
the %1 parameter, as in:
dir "%1" /-p /o:gn > "%temp%\Listing"
If you want just the directories (i.e., no files) then add the /ad
switch. However, the output is still pretty bad unless you're printing
out just the contents of that directory and not also its subdirectories
(by using the /s switch) since the dir listing pops out of the current
one to show each directory separately (i.e., you don't get a hierarhical
listing and instead just get a flat listing).
If you're looking for a hierarchical listing of a directory (and its
subdirectories) without the files under each one, replace the dir
command with the tree command, as in:
tree "%1" /a > "%temp%\Listing"
You could still use the single-directory "Print Directory Listing" as
mentioned before that used prin.bat under the Microsoft KB article that
Dave mentioned, and you could define another context menu to print the
hierarchical tree named, say, "Print Directory Tree" using a
printree.bat file as the action.
Other than possibly a larger fixed font when printing, you could replace
"start /w notepad /p" with "print". I would think you could use the DOS
print command instead of running Notepad, but I do like the smaller font
that results when using Notepad. Also, by using Notepad the filename
appears at the top of the printout. If command extensions are enabled
(the default under Windows 2000), the %date% and %time% environments are
defined in a new shell so you can somewhat ensure a unique filename when
creating the listing plus that name appears in the printout (if using
Notepad). Using the print command instead of Notepad eliminates the
screen flash when Notepad gets momentarily loaded.
I'm still pondering if I want to use Notepad for printing or to replace
it with the print command and eliminate the screen flash from the
momentary load of Notepad. Of course, you could eliminate the /p switch
for Notepad in the batch file and simply have it show the output and
then decide if you want to print it or save it as a file elsewhere; no
point in wasting paper unless that's what you always want to do. Since
you are running a batch file, you can add to it, so you could have
something like:
"Print Directory Listing":
@echo off
set tfile=%temp%\Directory Listing
if ["%date% at %time%"] == [" at "] goto NoCmdExt
echo Created: %date% at %time% > "%tfile%"
echo. >> "%tfile%"
:NoCmdExt
dir "%1" /-p /o:gn >> "%tfile%"
start /w notepad /p "%tfile%"
del "%tfile%"
exit
"Print Directory Tree":
@echo off
set tfile=%temp%\Directory Listing
if ["%date% at %time%"] == [" at "] goto NoCmdExt
echo Created: %date% at %time% > "%tfile%"
echo. >> "%tfile%"
:NoCmdExt
tree "%1" /a >> "%tfile%"
start /w notepad /p "%tfile%"
del "%tfile%"
exit
Or you could use PC Magazine's TreePrint utility that integrates into
Explorer (
http://www.pcmag.com/article2/0,4149,94767,00.asp), but
pcmag.com now charges for their downloads by making you subscribe. It
lets you include the files in the tree listing (but not their dates and
sizes). It lets you print the output or save it to a file (which you
could do by removing the /p switch from Notepad). I suppose I could
come up with a for loop that does a recursive CALL to walk through the
directories and include the files in the listing and which would dates
and sizes but I don't have a need for that level of detail yet. If I
really needed to manage lots of hosts and know what all software they
had installed then I'd start looking at software/hardware inventory
control products, like SiteKeeper (
http://snurl.com/31t5) which seems
cheap (but I haven't used the product so I don't know how robust it is,
or how robust is your need). If you don't mind having to walk around to
each host to run an inventory program (i.e., you're not managing
inventory via network and running inventory clients on each host), I
suppose somethinglike Belarc Advisor (free only for personal use) might
do. It has links to the files but doesn't itself show the dates and
sizes, but it does show the versions of the products.