Search This Blog

Google Analytics

Friday, January 23, 2009

Directory Listing Web Application in VBScript

I just came out with a quick and "dirty" method to perform simple Directory Listing. I mention "dirty" because it is in VBScript and thus will work only on Microsoft Internet Explorer.

<title>Directory Listing: Copyright © Loh Hon Chun</title>
<script language="JavaScript">
    window.defaultStatus = 'Directory Listing: Copyright © Loh Hon Chun';
a { color:#707070; text-decoration:none; }
a:hover { color:#000000; text-decoration:none; }
body {
    font-size: 9pt;
    color: #2F4F4F;
    FONT-FAMILY: Arial;
    margin-top: 20px;
    margin-left: 50px;
h1 {
    font-weight: bold;
    font-size: 18pt;
    font-family: Verdana;
    color: #BC8F8F;
.header {
    font-weight: bold;
    font-family: Verdana;
.displayMsg {
    font-weight: bold;
    font-size: 12pt;
    font-family: Verdana;
.errorMsg {
    color: #FF0000;
    font-weight: bold;
    font-size: 12pt;
    font-family: Verdana;
<h1>Directory Listing</h1>
<script language="VBScript">
Function RecurseFolders(thisFolder)
    Set objFolder = objFSO.GetFolder(thisFolder)
    Document.Write "<span class=""header"">" & objFolder & "</span>"
    For Each objFile in objFolder.Files
        Document.Write "    <a href=""" & objFolder.Path & "/" & objFile.Name & """>" & objFile.Name & "</a>"
    Document.Write ""
    If Not objFolder.Subfolders.Count = 0 Then
        For Each objSFolder in objFolder.SubFolders
    End If
End Function
Dim objFSO, objFolder, objFile, objSFolder
Dim folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
folder = InputBox("Please enter directory")
If objFSO.FolderExists(folder) Then
    Document.Write "<span class=""displayMsg"">Generating listing for <a href=""" & folder & """>" & folder & "</a></span>"
    Call RecurseFolders(folder)
    Document.Write "<span class=""errorMsg"">Not such directory <u>" & folder & "</u></span>"
End If

1 comment:

  1. Its really very easy to do the simple directory listing web application in VB Script. I like this method.


Do provide your constructive comment. I appreciate that.

Popular Posts