|
A Few Details Continued from A General-Purpose File-Deletion Script One potential problem with using the scripting host for time-consuming processes (like our recursive routine) is worth noting: The scripting host has no truly convenient built-in way to build a window on which you can indicate the progress being made. And since it is not uncommon for a hard disk to have more than 2,000 subfolders, the lack of feedback can be disconcerting. VBScript can create message boxes, of course, but message boxes force the user to click on OK constantly. We'll use instead a method that is part of the Windows Scripting Host and displays a sort of super-message box. This method allows you to build a message box that vanishes after a specified number of seconds have passed--whether or not the user has clicked on it. We'll pop this message box up after every 100 folders are visited and keep it on the screen for 1 second. We'll also include a little loop that makes sure the user really wants to proceed. Note that we've hard-coded the program to start in the root directory of C:. To use the code on another drive or directory, change the following line: Set TheFolder = FSO.GetFolder("C:\") to reflect your desired starting point. (Of course, you could also add another input routine that allowed users to set the starting folder.) Figure 1 shows our completed file-deletion script, which you can download as part of this issue's archive. As you can see, the Windows Scripting Host, together with the script language of your choice, has the potential to automate many mundane tasks on your system. Next: Figure 1: File deletion script. Published as Operating Systems in the 6/30/98 issue of PC Magazine. |
|
TOP |
Copyright (c) 1998 Ziff-Davis Inc. |