in reply to Re: Windows Scriptin Host & OLE.
in thread Windows Scriptin Host & OLE.

this may not be what you're looking for. It doesn't use OLE, but unless WSH files and folders are different it should do the job with some modifications.

This code takes a windows path and writes to c:\log.txt the contents of the given directory and all its subdirectories

Please feel free to comment on this code as I'm sure its not perfect.
#!/Perl/bin/perl use IO::File; use strict; print "Enter the directory to map: "; my $dir = <STDIN>; chomp($dir); my $log = new IO::File; $log->open(("> c:\\log.txt")) or die "$!"; $log->write("Map of: ".$dir,length("Map of: ".$dir)); $dir =~ s{\\}{\\\\}g; mapMe($dir); $log->close; ##Recursive routine to print out all the files & folders under a given + root node sub mapMe { #Get the parameter my $handle = shift; #Open the directory passed to the subroutine opendir(SPROUT,$handle); #read the entries my @entries = readdir(SPROUT); #Close the directory closedir(SPROUT); my $log_entry; #Start @ 2 to skip . & .. entries foreach my $i (2..scalar(@entries)) { #Format the handle for the next call my $param_handle = $handle."\\".$entries[$i]; #If its a directory and its not null if(opendir(TEST,$param_handle) and $entries[$i]) { #Close the directory closedir(TEST); #Strip the handle for log writing purposes $handle =~ s{\\\\}{\\}g; #Construct and write the log $log_entry = "\n".$handle."\\".$entries[$i]."\n"; $log->write($log_entry,length($log_entry)); #recurse the directory mapMe($param_handle); } elsif($entries[$i]) { #Construct and write the log $log_entry = "*".$entries[$i]."\n"; $log->write($log_entry,length($log_entry)); } } }
I hope this will help you out.