<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>The Scripting Guys' First Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/gstemp/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/gstemp/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:10:18 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Windows XP Service Pack 2 Application Compatibility Scripts</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/windows-xp-service-pack-2-application-compatibility-scripts</link>
      <pubDate>Wed, 27 Oct 2004 15:34:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/10/27/windows-xp-service-pack-2-application-compatibility-scripts/</guid>
      <description><![CDATA[One of the developer resources useful to IT folks that you might overlook in the vastness of...]]></description>
      <content:encoded><![CDATA[<p><font face="Arial" size="2">One of the developer resources useful to IT folks that you might overlook in the vastness of microsoft.com is -- deep breath -- the </font><a href="https://www.microsoft.com/downloads/details.aspx?FamilyId=9300BECF-2DEE-4772-ADD9-AD0EAF89C4A7&amp;displaylang=en"><font face="Arial" size="2">Application Compatibility Testing and Mitigation Guide for Windows XP Service Pack 2</font></a></p> <p><font face="Arial" size="2">This download contains documentation and scripts for handling issues of application compatibility that also deal with problems that most sysadmins will face in deploying SP2.</font></p> <p><font face="Arial" size="2">On the </font><a href="https://www.microsoft.com/technet/scriptcenter/solutions/default.mspx"><font face="Arial" size="2">Scripting Solutions Center</font></a><font face="Arial" size="2">&nbsp;of TechNet Script Center we've posted a set of supplemental scripts with their own readme that show how to perform most of the tasks in the Application Compatibility Guide, using WMI or the new Windows Firewall COM object model.&nbsp; The Guide's scripts use mostly WSH and batch files.&nbsp; The two sets of scripts complement each other&nbsp;-- there's something for everyone's needs and scripting preferences.</font></p> <p><a href="https://www.microsoft.com/technet/scriptcenter/solutions/appcompat/default.mspx"><font face="Arial" size="2">Windows XP Service Pack 2 Application Compatibility - Supplemental Scripts</font></a></p> <p><font face="Arial" size="2">Let us know how you're handling the deployment and management of SP2 and what issues you're encountering at:<br /></font><a href="mailto:scripter@microsoft.com"><font face="Arial" size="2">scripter@microsoft.com</font></a></p>]]></content:encoded>
    </item>
    <item>
      <title>New Scripting Guys webcast on scripting Windows XP Service Pack 2 available on-demand</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/new-scripting-guys-webcast-on-scripting-windows-xp-service-pack-2-available-on-demand</link>
      <pubDate>Mon, 25 Oct 2004 14:54:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/10/25/new-scripting-guys-webcast-on-scripting-windows-xp-service-pack-2-available-on-demand/</guid>
      <description><![CDATA[The latest Scripting Guys' Webcast took place Friday, October 8th, and is now available from the...]]></description>
      <content:encoded><![CDATA[<p><font face="Arial">The latest Scripting Guys' Webcast took place Friday, October 8th, and is now available from the TechNet Webcast archives in on-demand video form.</font></p> <p><font face="Arial">It's called Scripting with Microsoft Windows XP Service Pack 2: SOS! and you can find it at:<br /></font><a href="https://msevents.microsoft.com/cui/eventdetail.aspx?EventID=1032259299&amp;Culture=en-US"><font face="Arial">https://msevents.microsoft.com/cui/eventdetail.aspx?EventID=1032259299&amp;Culture=en-US</font></a></p> <p><font face="Arial">By the way, you now need to register for the event to view the on-demand video afterwards as well as the event itself, so you have to click the "Register for event" link in the left-hand pane.</font></p> <p><font face="Arial">Here's what Greg said about it:</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial" color="#000080">This Webcast -- to be presented by the scripting songbird himself, Mr. Peter Costantini -- ... will introduce you to some of the new scripting objects found in XP Service Pack 2. Perhaps more important, it will also tell you how you can get your scripts to work with Service Pack 2 in the first place; by default, the new Windows Firewall prevents you from using scripts to remotely manage a computer running Service Pack 2. But don't despair: Peter will show you how to work around that issue, as well as show you how to do such things as manage the new Pop-Up blocker in Internet Explorer.</font></p> <p><font face="Arial">The webcast goes into some depth on:</font></p> <ul> <li><font face="Arial">Deploying and blocking deployment of SP 2 with scripting</font> <li><font face="Arial">Re-enabling remote administration on SP 2 hosts</font> <li><font face="Arial">Windows Firewall scripting</font> <li><font face="Arial">Scripting networking configuration</font> <li><font face="Arial">Scripting local security configuration</font> <li><font face="Arial">Scripting Internet applications</font> <li><font face="Arial">Other scriptable areas of SP 2</font></li></ul> <p><font face="Arial">And it shows code examples for each area.</font></p> <p><font face="Arial">Here's a bit of dialogue from the section of the webcast on scripting registry changes:</font></p> <p> <hr id="null" /> <p></p> <p><font face="Arial">Dr. Scripto:</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial">The registry is Windows' heart of darkness.&nbsp; Mister Kurtz designed it.</font></p> <p><font face="Arial">Peter:</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial">Think back to that English lit class you used to fall asleep in.&nbsp; Remember Joseph Conrad's novel?&nbsp; What was that they said about Mister Kurtz? "Mistah Kurtz, he dead"&nbsp; And not only is Mister Kurtz dead, but he didn't tell anybody where he put the blueprints for the registry.</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial">So the registry has grown organically, with its own logic&nbsp; It's really less a database than an ecosystem, a sort of mysterious and chaotic digital rain forest.&nbsp; It's a place of teeming life ... and violent death.</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial">Listen!&nbsp; Can you hear that flock of DWORDS high in the treetops of HKEY_LOCAL_MACHINE?&nbsp; And look!&nbsp; There goes a sinuous REG_SZ slithering through the undergrowth of HKEY_CLASSES_ROOT!</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial">We can never tame the registry, but with patience we can learn to appreciate the ebb and flow of its seasons.&nbsp; And very cautiously, we can make small changes in it.&nbsp; Now as you may be aware, that's a controversial topic.</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial">Mark Minasi, the columnist for Windows IT Pro magazine, has suggested that the standard registry warning in our documentation should be changed to read: "Manually changing the registry can cause sudden involuntary sex change."</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial">Now Mark is a very smart and funny guy, but there is absolutely no truth to his allegation.</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial">I do admit that we have heard completely unsubstantiated rumors that scripting the registry can cause hair to grow on the palms of your hands and, in extreme cases, temporary blindness and insanity.</font></p> <p dir="ltr" style="MARGIN-RIGHT: 0px"><font face="Arial">But we want to reassure you that we have not been able to verify one single case of this and that there is almost no chance that this will happen to you.</font></p> <p> <hr id="null" /> <p></p> <p><font face="Arial">BabyScript</p></font>]]></content:encoded>
    </item>
    <item>
      <title>Hey, Scripting Guy! How Can I Stop a Script Partway Through?</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/hey-scripting-guy-how-can-i-stop-a-script-partway-through</link>
      <pubDate>Fri, 03 Sep 2004 13:52:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/09/03/hey-scripting-guy-how-can-i-stop-a-script-partway-through/</guid>
      <description><![CDATA[https://www.microsoft.com/technet/scriptcenter/resources/qanda/aug04/hey0830.mspx]]></description>
      <content:encoded><![CDATA[<a href="https://www.microsoft.com/technet/scriptcenter/resources/qanda/aug04/hey0830.mspx"><font face="Arial">https://www.microsoft.com/technet/scriptcenter/resources/qanda/aug04/hey0830.mspx</font></a>]]></content:encoded>
    </item>
    <item>
      <title>Hey, Scripting Guy! How Can I Prompt a User for Input?</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/hey-scripting-guy-how-can-i-prompt-a-user-for-input</link>
      <pubDate>Fri, 03 Sep 2004 13:51:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/09/03/hey-scripting-guy-how-can-i-prompt-a-user-for-input/</guid>
      <description><![CDATA[https://www.microsoft.com/technet/scriptcenter/resources/qanda/aug04/hey0831.mspx]]></description>
      <content:encoded><![CDATA[<a href="https://www.microsoft.com/technet/scriptcenter/resources/qanda/aug04/hey0831.mspx"><font face="Arial">https://www.microsoft.com/technet/scriptcenter/resources/qanda/aug04/hey0831.mspx</font></a>]]></content:encoded>
    </item>
    <item>
      <title>Hey, Scripting Guy! How Can I Create a Folder on a Remote Computer?</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/hey-scripting-guy-how-can-i-create-a-folder-on-a-remote-computer</link>
      <pubDate>Fri, 03 Sep 2004 13:51:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/09/03/hey-scripting-guy-how-can-i-create-a-folder-on-a-remote-computer/</guid>
      <description><![CDATA[https://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0901.mspx]]></description>
      <content:encoded><![CDATA[<a href="https://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0901.mspx"><font face="Arial">https://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0901.mspx</font></a>]]></content:encoded>
    </item>
    <item>
      <title>Hey, Scripting Guy! How Can I Enumerate All the Objects in an Active Directory OU?</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/hey-scripting-guy-how-can-i-enumerate-all-the-objects-in-an-active-directory-ou</link>
      <pubDate>Fri, 03 Sep 2004 13:50:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/09/03/hey-scripting-guy-how-can-i-enumerate-all-the-objects-in-an-active-directory-ou/</guid>
      <description><![CDATA[https://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0902.mspx]]></description>
      <content:encoded><![CDATA[<a href="https://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0902.mspx"><font face="Arial">https://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0902.mspx</font></a>]]></content:encoded>
    </item>
    <item>
      <title>Hey, Scripting Guy! Daily Column</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/hey-scripting-guy-daily-column</link>
      <pubDate>Fri, 03 Sep 2004 13:44:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/09/03/hey-scripting-guy-daily-column/</guid>
      <description><![CDATA[https://www.microsoft.com/technet/scriptcenter/resources/qanda/default.mspx]]></description>
      <content:encoded><![CDATA[<a href="https://www.microsoft.com/technet/scriptcenter/resources/qanda/default.mspx"><font face="Arial">https://www.microsoft.com/technet/scriptcenter/resources/qanda/default.mspx</font></a>]]></content:encoded>
    </item>
    <item>
      <title>Extreme file and folder scripting: Listing a directory tree recursively - Day 3 – Bonus script: Using WMI with LIKE</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/extreme-file-and-folder-scripting-listing-a-directory-tree-recursively-day-3-bonus-script-using-wmi-with-like</link>
      <pubDate>Fri, 13 Aug 2004 12:43:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/08/13/extreme-file-and-folder-scripting-listing-a-directory-tree-recursively-day-3-bonus-script-using-wmi-with-like/</guid>
      <description><![CDATA[&nbsp; When I showed these scripts to Dean, he thought there had to be an easier way to recurse...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal" style="MARGIN: 0in 0in 0pt"></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">&nbsp;</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">When I showed these scripts to Dean, <font size="2">he</font> thought there had to be an easier way to recurse through a directory tree with WMI, and he found it.<span style="mso-spacerun: yes">&nbsp; </span>The only caveat is that you must run it on Windows XP or Windows Server 2003.<span style="mso-spacerun: yes">&nbsp; </span>This is because WMI Query Language, the SQL dialect that you use with the ExecQuery method of SwbemServices, first added the LIKE keyword in Windows XP (see <a href="https://msdn.microsoft.com/library/en-us/wmisdk/wmi/like_operator.asp">https://msdn.microsoft.com/library/en-us/wmisdk/wmi/like_operator.asp</a>).</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">In this case, LIKE enables you to query for all directories that contain a specific string, surrounded by percent signs, for example: "%c:\\ff%" (remember that WQL queries require two backslashes rather than one to delimit file paths).<span style="mso-spacerun: yes">&nbsp; </span>This would include all subdirectories of c:\ff and their subdirectories.<span style="mso-spacerun: yes">&nbsp; </span>In other words, LIKE enables you to use WQL's equivalent of wildcards.<span style="mso-spacerun: yes">&nbsp; </span>You can also use the percent sign at just one side of the string.<span style="mso-spacerun: yes">&nbsp; </span>In this script we use "c:\\ff%", which returns any path on c: drive that begins with "ff".<span style="mso-spacerun: yes">&nbsp; </span>Keep in mind that this will also return not just the subdirectories of c:\ff, but also any other top level folders that begin with ff, such as c:\ffx.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">The query including LIKE in this script seems to run very slowly, at least on my computer.<span style="mso-spacerun: yes">&nbsp; </span>That may be because my computer is old and cantankerous, like me.<span style="mso-spacerun: yes">&nbsp; </span>Or it may be because WMI has to search the whole file system to make sure there are no other matches that are LIKE the string.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Here's Dean's script, which I suppose we could call Files-list-recurse-like-wmi.vbs, except that the name is getting too long.<span style="mso-spacerun: yes">&nbsp; </span>Call it what you will.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 4pt; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.25in; BORDER-LEFT: windowtext 1pt solid; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-element: para-border-div"> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">strComputer = "."</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">strFolderRoot = "c:\\ff"</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Set objWMIService = GetObject("winmgmts:" _</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>&amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2")</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Set colFolders = objWMIService.ExecQuery _</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>("Select * from Win32_Directory where Name Like '" &amp; strFolderRoot &amp; "%'")</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">For Each objFolder in colFolders</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>Wscript.Echo "Folder: " &amp; objFolder.Name</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>strTMP = Replace(Mid(objFolder.Name,4,Len(objFolder.Name)),"\","\\")<span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>strQuery = "SELECT * FROM CIM_DataFile WHERE Drive = 'c:' " &amp; _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;&nbsp; </span>"AND Path = '\\" &amp; strTMP &amp; "\\'"</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>Set colFiles = objWMIService.ExecQuery(strQuery)</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>On Error Resume Next</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>For Each objFile in colFiles</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span>WScript.Echo "File: " &amp; objFile.Name</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>Next</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Next</font></p></div> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p>]]></content:encoded>
    </item>
    <item>
      <title>Extreme file and folder scripting: Listing a directory tree recursively - Day 2 – Using WMI</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/extreme-file-and-folder-scripting-listing-a-directory-tree-recursively-day-2-using-wmi</link>
      <pubDate>Wed, 11 Aug 2004 14:47:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/08/11/extreme-file-and-folder-scripting-listing-a-directory-tree-recursively-day-2-using-wmi/</guid>
      <description><![CDATA[BabyScript &nbsp; Now that we've glanced at recursion out of the corner of our eye (on Day 1) and...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">BabyScript</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Now that we've glanced at recursion out of the corner of our eye (on Day 1) and lived, it's time to stare straight-on into the unspeakable horror of the Medusa Code.<span style="mso-spacerun: yes">&nbsp; </span>If you have sunglasses, please put them on now.<span style="mso-spacerun: yes">&nbsp; </span>If you try to speak its name, Files-list-recurse-wmi.vbs, we won't be responsible for what might happen to your tongue.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 4pt; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.25in; BORDER-LEFT: windowtext 1pt solid; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-element: para-border-div"> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">strComputer = "."</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">strDrive = "c:"</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">strPath = "ff" 'Use double backslashes in path if necessary</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">strPathAlt = Replace(strPath, "\\", "\")</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">strName = strDrive &amp; "\" &amp; strPathAlt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Set objWMIService = GetObject("winmgmts:\\" &amp; strComputer)</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">WScript.Echo strName</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Set colFiles = objWMIService.ExecQuery _</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>("SELECT * FROM CIM_DataFile WHERE Drive = '" &amp; strDrive &amp; _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>"' AND Path = '\\" &amp; strPath &amp; "\\'")</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">For Each objFile in colFiles</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>WScript.Echo objFile.Name</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Next</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Set colFolders = objWMIService.ExecQuery _</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>("ASSOCIATORS OF {Win32_Directory.Name='" &amp; strName &amp; "'} " _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>&amp; "WHERE AssocClass = Win32_Subdirectory " _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>&amp; "ResultRole = PartComponent")</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">For Each objFolder in colFolders</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>WScript.Echo objFolder.Name</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>strFolderPath = Replace(objFolder.Path, "\", "\\")</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>strFilePath = strFolderPath &amp; objFolder.FileName &amp; "\\"</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>Set colFiles = objWMIService.ExecQuery _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;&nbsp; </span>("SELECT * FROM CIM_DataFile WHERE Drive = '" &amp; strDrive &amp; _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;&nbsp; </span>"' AND Path = '" &amp; strFilePath &amp; "'")</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>For Each objFile in colFiles</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span>WScript.Echo objFile.Name</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>Next</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>ShowSubFolders objFolder.Name</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Next</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><o:p><font face="Courier New" size="2">&nbsp;</font></o:p></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Sub ShowSubFolders(strSubFolder)</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Set colSubFolders = objWMIService.ExecQuery _</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>("ASSOCIATORS OF {Win32_Directory.Name='" &amp; strSubFolder &amp; "'} " _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>&amp; "WHERE AssocClass = Win32_Subdirectory " _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;</span>&amp; "ResultRole = PartComponent")</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">For Each objSubFolder in colSubFolders</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>Wscript.Echo objSubFolder.Name</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>strSubFolderPath = Replace(objSubFolder.Path, "\", "\\")</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>strSubFilePath = strSubFolderPath &amp; objSubFolder.FileName &amp; "\\"</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>Set colSubFiles = objWMIService.ExecQuery _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;&nbsp; </span>("SELECT * FROM CIM_DataFile WHERE Drive = '" &amp; strDrive &amp; _</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;&nbsp; </span>"' AND Path = '" &amp; strSubFilePath &amp; "'")</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>For Each objSubFile in colSubFiles</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span>WScript.Echo objSubFile.Name</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>Next</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font size="2"><font face="Courier New"><span style="mso-spacerun: yes">&nbsp; </span>ShowSubFolders objSubFolder.Name</font></font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">Next</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">End Sub</font></p></div> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Here's the output from the same test folder:</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 4pt; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 1pt; MARGIN-LEFT: 0.25in; BORDER-LEFT: windowtext 1pt solid; MARGIN-RIGHT: 0in; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-element: para-border-div"> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">C:\scripts&gt;files-list-recurse-wmi.vbs</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\disklog.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\otherfile.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\scriptlog.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\servicelog.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\servicestatus.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\testfile.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff1</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff1\disklog.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff1\scriptlog.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff1\ff3</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff1\ff3\disklog.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff1\ff3\scriptlog.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff2</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff2\disk.log</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff2\otherfile.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff2\service.log</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff2\ff4</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff2\ff4\disk.log</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff2\ff4\otherfile.txt</font></p> <p class="Code" style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><font face="Courier New" size="2">c:\ff\ff2\ff4\service.log</font></p></div> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Hmm, looks kind of familiar, doesn't it?<span style="mso-spacerun: yes">&nbsp; </span>You mean, it takes all that code in WMI to produce the same output?<span style="mso-spacerun: yes">&nbsp; </span>Yep.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Actually, this script goes beyond the bonus script in the webcast.<span style="mso-spacerun: yes">&nbsp; </span>That one only listed folders and subfolders.<span style="mso-spacerun: yes">&nbsp; </span>This one displays the full Monty, folders, sub-folders and all their files.<span style="mso-spacerun: yes">&nbsp; </span>But it takes quite a few more lines of code than the FSO version.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">We start out by assigning the drive and top folder names separately, so we can take them apart later.<span style="mso-spacerun: yes">&nbsp; </span>WMI lets us (or makes us) define the elements of a file path separately.<span style="mso-spacerun: yes">&nbsp; </span>Then we'll query the CIM_DataFile class for file instances, filtering with the separate drive and path variables.<span style="mso-spacerun: yes">&nbsp; </span>Note the lovable quirk of WQL that we have to put double backslashes on both sides of the path.<span style="mso-spacerun: yes">&nbsp; </span>This gives rise to some of the contortions in this script, as other methods of the class require a path separated by single backslashes rather than double ones.<span style="mso-spacerun: yes">&nbsp; </span>VBScript is there to help with the Replace function, that lets us pass it a string, a substring to replace and second substring with which to replace the first.<span style="mso-spacerun: yes">&nbsp; </span>So we use it to replace double backslashes with single backslashes and vice versa.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">At this point, we've only listed the files in the top folder.<span style="mso-spacerun: yes">&nbsp; </span>What to do next?<span style="mso-spacerun: yes">&nbsp; </span>Well, at this point we need a way to get at the subfolders in the current folder, but Win32_Directory doesn't give us anything as handy as the FSO SubFolders property.<span style="mso-spacerun: yes">&nbsp; </span>What we do have, though, is something called an association class.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Now both Greg and Dr. Scripto told me not to talk about association classes, and even Dean had reservations.<span style="mso-spacerun: yes">&nbsp; </span>That way lies madness, they said.<span style="mso-spacerun: yes">&nbsp; </span>Association classes are so Byzantine, so baroque, so rococo, that people will run screaming away from scripting and never return.<span style="mso-spacerun: yes">&nbsp; </span>OK, I said, I’m sure they’ll take it on faith that they just work.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Then I tossed and turned that night because I knew I couldn’t do this to our readers.<span style="mso-spacerun: yes">&nbsp; </span>So here’s what an association class is: a class that associates two other classes or managed resources.<span style="mso-spacerun: yes">&nbsp; </span>So far, so good.<span style="mso-spacerun: yes">&nbsp; </span>In this case, the association class is Win32_Subdirectory, which associates two different sets of instances of Win32_Directory.<span style="mso-spacerun: yes">&nbsp; </span>One of the two Win32_Directory instances is called GroupComponent, and it represents the parent directory of the two related instances.<span style="mso-spacerun: yes">&nbsp; </span>The other is called PartComponent, and it represents the subordinate directory or directories in the relationship.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">So when this ASSOCIATORS OF query:</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"ASSOCIATORS OF {Win32_Directory.Name='" &amp; strName &amp; "'} " _<o:p></o:p></span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">&nbsp;</span>&amp; "WHERE AssocClass = Win32_Subdirectory " _<o:p></o:p></span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><span style="mso-spacerun: yes">&nbsp;</span>&amp; "ResultRole = PartComponent"<o:p></o:p></span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">filters for "ResultRole = PartComponent", it's asking for the directories that are subdirectories of the directory specified by strName.<span style="mso-spacerun: yes">&nbsp; </span>The query returns a collection of these associated subdirectories, which we assign to an object reference, colSubFolders.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">If you want to pursue this, the WMI SDK documentation for Win32_Subdirectory is at:</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">https://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_subdirectory.asp</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Besides using the keywords “ASSOCIATORS OF” in a WQL query, as this script does, you can also call the AssociatorsOf method of the SwbemServices object, which is the kind of object referenced by objWMIService in this line:</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">Set objWMIService = GetObject("winmgmts:\\" &amp; strComputer)<o:p></o:p></span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Then when you call objWMIService.AssociatorsOf(<i style="mso-bidi-font-style: normal">parameters</i>), the only required parameter (there are also several optional ones including association class) is the object path of a managed resource or resources, such as:</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"Win32_Service.Name='Alerter'"<o:p></o:p></span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Other association classes work in slightly different ways, but all enable you to associate related instances of classes.<span style="mso-spacerun: yes">&nbsp; </span>For a fuller explanation of association classes, see:</p> <ul> <li> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="FONT-SIZE: 11.5pt">"Declaring an Association Class"</span> in the WMI SDK (this one is at a system programming level)<br /><a href="https://msdn.microsoft.com/library/en-us/wmisdk/wmi/declaring_an_association_class.asp">https://msdn.microsoft.com/library/en-us/wmisdk/wmi/declaring_an_association_class.asp</a></div></li><span style="FONT-SIZE: 11.5pt"> <li> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt"><font size="3">ASSOCIATORS OF Statement<br /></font><font size="3"><a href="https://msdn.microsoft.com/library/en-us/wmisdk/wmi/associators_of_statement.asp">https://msdn.microsoft.com/library/en-us/wmisdk/wmi/associators_of_statement.asp</a></font></div></li> <li> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt">SWbemServices.AssociatorsOf</span> in the WMI SDK<br /><a href="https://msdn.microsoft.com/library/en-us/wmisdk/wmi/swbemservices_associatorsof.asp">https://msdn.microsoft.com/library/en-us/wmisdk/wmi/swbemservices_associatorsof.asp</a></div></li> <li> <div class="MsoNormal" style="MARGIN: 0in 0in 0pt">"CIM Class Types" in the <i style="mso-bidi-font-style: normal">Windows 2000 Scripting Guide<br /></i><a href="https://www.microsoft.com/resources/documentation/windows/2000/server/scriptguide/en-us/sas_wmi_kzqu.mspx">https://www.microsoft.com/resources/documentation/windows/2000/server/scriptguide/en-us/sas_wmi_kzqu.mspx</a></div></li></ul> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Have you run screaming yet?<span style="mso-spacerun: yes">&nbsp; </span>If not, you've become one of the few, the proud, the ASSOCIATORS.<span style="mso-spacerun: yes">&nbsp; </span>We're working on a secret handshake, but you can tell members of the confraternity by the glazed look in their eyes.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">But we're not quite done yet.<span style="mso-spacerun: yes">&nbsp; </span>Once we've used the association class to get the subfolders, we still have to loop through the collection and then, as with FSO, the subroutine has to call itself recursively to loop through any subfolders of the subfolders.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">I hope it goes without saying that if you wanted to perform this astounding feat on a remote machine, you could just change line 1 to:</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><span style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">strComputer = "computer1"<o:p></o:p></span></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">where computer1 is an accessible host on your network on which you have administrative privileges.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">So we've done it.<span style="mso-spacerun: yes">&nbsp; </span>We've actually walked a directory tree using both FileSystemObject and WMI.<span style="mso-spacerun: yes">&nbsp; </span>Let the high-fiving and end-zone dances (or, for those of the soccer persuasion, "Gooooooooool" celebration) begin.</p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">I know you're thinking to yourselves, but you're too polite to ask: Um, couldn't you do all this in one line with <b style="mso-bidi-font-weight: normal">dir /s</b>?<span style="mso-spacerun: yes">&nbsp; </span>Well, actually, um, I guess so (Dr. Scripto, help me out here!).<span style="mso-spacerun: yes">&nbsp; </span>But then we wouldn't have had all this fun.<span style="mso-spacerun: yes">&nbsp; </span>Nor would we appreciate what <b style="mso-bidi-font-weight: normal">dir</b> has to do under the hood.<span style="mso-spacerun: yes">&nbsp; </span>If you ever wanted to customize this or add some functionality that does something to or within the resulting directory tree, you wouldn't know how.<span style="mso-spacerun: yes">&nbsp; </span>And, most important, we would not have achieved such a deep understanding of extreme file and folder scripting with both FSO and WMI.</p></p>]]></content:encoded>
    </item>
    <item>
      <title>Extreme file and folder scripting: Listing a directory tree recursively. Day 1 – Using FilesSystemObject</title>
      <link>https://docs.microsoft.com/archive/blogs/gstemp/extreme-file-and-folder-scripting-listing-a-directory-tree-recursively-day-1-using-filessystemobject</link>
      <pubDate>Tue, 10 Aug 2004 11:31:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gstemp/2004/08/10/extreme-file-and-folder-scripting-listing-a-directory-tree-recursively-day-1-using-filessystemobject/</guid>
      <description><![CDATA[BabyScript
&nbsp;
If you attended Day 3 of the Scripting Week webcasts, "Scripting Files and...]]></description>
      <content:encoded><![CDATA[<P class=MsoNormal style="MARGIN: 0in 0in 0pt">BabyScript</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">If you attended Day 3 of the Scripting Week webcasts, "Scripting Files and Folders Makes Me Happy" https://go.microsoft.com/fwlink/?LinkId=30795, you may recall an odd and vaguely menacing script in the second section on WMI.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It bristled with strange code and was labeled "Bonus: listing a folder tree," but we didn't discuss it.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>As Dr. Scripto said, merely looking at it could turn you to stone.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">OK, so Dr. Scripto exaggerates a little.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>But we're going to call that script the Medusa Code because it sounds cool, kind of like the name of an action movie.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We'll come back to the Medusa Code later, so stay on the edge of your seats.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>But for starters we're going to talk about what the Medusa Code was trying to accomplish in the first place: listing a directory tree recursively.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Ah, "recursively": there's a word that rolls off the tongue!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Dr. Scripto loves to say it, although I had always suspected he wasn't too sure what it meant.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>I wasn't either, so I got out my dictionary and checked.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>There was no listing for "recursively," but it had a definition for "recursive": "1: of, relating to, or involving mathematical recursion."</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Doh!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Of course!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Elementary, my dear Scripto.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Not being of a mathematical bent (I mean, being kind of bent, but not mathematically so), I forged ahead to the second definition: "2: of, relating to, or constituting a procedure that can repeat itself indefinitely or until a specified condition is met."</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Hmmm, repeating itself indefinitely &#8211; sounds like Greg on a bad day.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>At that point, I threw the dictionary on my main pile (my office is organized by piles) and opened Notepad.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>When something doesn't make sense, it usually helps to open Notepad and start writing code.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">At that point, Dr. Scripto whispered in my ear: "Don't worry about 'recursive.'<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Just write a script that walks a directory tree and lists all the files and folders in each branch."<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Aha, my muse had spoken.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>"But that's not repeating itself indefinitely," I whined.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>"No," replied Dr. Scripto, "just repeating itself until a specified condition is met.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>And that condition?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>That no more sub-folders can be found to recurse through."</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">If you'll recall from the webcast, with WMI you can easily display the names of all the files or folders on a computer or on a particular disk drive.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>But you probably don&#8217;t need to do that too often, and when you do, it can take a long time.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>When you get down to listing all the files or folders in a specific directory, you run into a shortcoming of some methods of the WMI file and folder classes: they only list the first level of files or folders even if there are sub-folders and files in them.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In other words, they don't walk down all the branches of the directory tree.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Ipso est, they're not recursive.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">To show how to list a directory tree recursively, we're going to take a little detour back to the FileSystemObject.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>You'll recall that the webcast began with FSO and worked up to the WMI file and folder classes.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>So we'll follow the same path: before we get to WMI and the Medusa Code, it's a little bit easier to see how recursion works with FSO because the rest of the code is simpler.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Here&#8217;s a script that uses FSO to list all files in a folder and its sub-folders recursively (we'll call it Files-list-recurse-fso.vbs):</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 4pt; PADDING-BOTTOM: 1pt; BORDER-LEFT: windowtext 0.5pt solid; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 0.5pt solid">
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>Const FOR_READING = 1</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>strFolder = "c:\ff"</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>Set objFSO = CreateObject("Scripting.FileSystemObject")</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>Set objFolder = objFSO.GetFolder(strFolder)</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>WScript.Echo objFolder.Path</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>Set colFiles = objFolder.Files</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>For Each objFile In colFiles</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>WScript.Echo objFile.Path</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>Next</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>ShowSubFolders(objFolder)</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>Sub ShowSubFolders(objFolder)</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Set colFolders = objFolder.SubFolders</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For Each objSubFolder In colFolders</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>WScript.Echo objSubFolder.Path</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Set colFiles = objSubFolder.Files</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>For Each objFile In colFiles</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>WScript.Echo objFile.Path</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Next</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>ShowSubFolders(objSubFolder)</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT size=2><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Next</FONT></FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>End Sub</FONT></P></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Here's the output I got by running the script on a test folder:</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 4pt; BACKGROUND: #e0e0e0; PADDING-BOTTOM: 1pt; BORDER-LEFT: windowtext 0.5pt solid; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 0.5pt solid">
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\scripts&gt;files-list-recurse-fso.vbs</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\disklog.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\otherfile.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\scriptlog.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\servicelog.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\servicestatus.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\testfile.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff1</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff1\disklog.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff1\scriptlog.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff1\ff3</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff1\ff3\disklog.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff1\ff3\scriptlog.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff2</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff2\disk.log</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff2\otherfile.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff2\service.log</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff2\ff4</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff2\ff4\disk.log</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff2\ff4\otherfile.txt</FONT></P>
<P class=Code style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 4pt 0.25in; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt"><FONT face="Courier New" size=2>C:\ff\ff2\ff4\service.log</FONT></P></DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">The script is pretty straightforward for the most part.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It gets the folder specified by the variable strFolder (in this case, c:\ff), then gets a collection of the files in that folder and loops through it with a For Each loop, displaying the full path of each one.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>A nice feature of the FileSystemObject is that Folder objects include a Files property that's a collection of all the files in the folder.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>How logical!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>How'd they ever come up with that?</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">But take a closer look at that Sub. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>What's it doing there?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>By jingo, Dr. Scripto, it's calling itself!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Is that legal?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Actually, as Dr. Scripto reassures me, that's what a recursive subroutine does, kind of like a dog chasing its own tail.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Besides the Files collection, FSO Folder objects have a SubFolders collection that includes &#8212; you'll never guess &#8212; all the folders contained within the folder.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Very handy.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We can use SubFolders to loop through each subfolder in the top-level folder, then get the collection the files in each and loop through that, displaying each one.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Then, within the top For Each loop for subfolders, the sub-routine calls itself, passing itself the name of each subfolder in the collection successively.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This is the key to how it can drill down through the levels of a directory tree.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>There are only three levels in the output example, but the script will keep drilling down &#8212; recursing &#8212; until it hits oil or the bottom level of the tree.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Is that crystal clear now?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you want to see this in action (and think you can handle this much fun), you could run the script in the Microsoft Script Debugger and watch the variables change through all those loops. <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>If you start to get dizzy, just look away.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>For more information, Greg talked about how to run scripts in the debugger during our August 4 webcast "What Do You Want To Script Today?" https://msevents.microsoft.com/CUI/EventDetail.aspx?culture=en-US&amp;EventID=1032255873&amp;EventCategory=5</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">Incidentally, if you want to read a directory tree on a remote machine, FSO allows you to use a UNC path, such as "\\computer\share".<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>So you could change line 2 to:</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">strFolder = "\\server1\c$\ff"<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">and display that tree recursively, provided of course that administrative shares are enabled on server1 and that you have administrative credentials on the machine.</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt">More soon about doing this with WMI.</P>]]></content:encoded>
    </item>
  </channel>
</rss>