Page 1 of 1

How to build this VBscript into a HTA ?

Posted: Tue May 31, 2011 10:58 pm
by hackoo
Hi ! I made a vbscript to search files by name and i want to build it into a HTA
so i found on the Net a HTA that list all files on one drive or all drives but i want to modifie it to do like in my script i mean the results must be in a dynamic Table and if the search includes image files will be displayed as thumbnails.
Thank You !

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META http-equiv=Content-Type content="text/html; CHARSET=iso-8859-1">
<title>Example</title>
<style type="text/css">
body {
font-family:Verdana;
font-size: 12px;
color: #49403B;
background: #FFFFFF;
}
hr {
color: #D84419;
}

button {
font-family:Verdana;
font-size: 14px;
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#D84419, EndColorStr=#ffffff);
height: 30px;
width: 150px;
font-weight: bold;
}
</style>
<script language="vbscript" type="text/vbscript">

Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim strHTML : strHTML = ""
Sub Window_Onload()
Center_HTA 500, 500
PopulateFiles(drp_Drives)
End Sub
Sub Center_HTA( widthX, heightY )
self.ResizeTo widthX, heightY
self.MoveTo (screen.Width - widthX)/2, (screen.Height - heightY)/2
End Sub
Sub PopulateFiles(dropdown_obj)
For Each objDrive In objFSO.Drives
If objDrive.DriveType = 2 Then
Set objOption = Document.createElement("OPTION")
objOption.Text = objDrive.DriveLetter & ":"
objOption.Value = objDrive.DriveLetter & ":"
dropdown_obj.Add(objOption)
End If
Next
End Sub
Sub btn_DoIt_onClick()
If drp_Drives.Value = "All" Then
For Each objDrive In objFSO.Drives
If objDrive.DriveType = 2 Then
On Error Resume Next
Set objDrive = objFSO.GetFolder(drp_Drives.Value)
If Err.Number = 0 Then
spn_Status.InnerHTML = "Please wait...."
Call GetSubFolders( objDrive )
Else
MsgBox "Drive: " & objDrive.DriveLetter & ". Error: " & Err.Number & Chr(32) & Err.Description
End If
On Error GoTo 0
End If
Next
Else
On Error Resume Next
Set objDrive = objFSO.GetFolder(drp_Drives.Value)
If Err.Number = 0 Then
spn_Status.InnerHTML = "Please wait...."
Call GetSubFolders( objDrive )
Else
MsgBox "Drive: " & objDrive.DriveLetter & ". Error: " & Err.Number & Chr(32) & Err.Description
End If
On Error GoTo 0
End If
spn_Status.InnerHTML = strHTML
End Sub
Sub GetSubFolders( oFolder )
On Error Resume Next
Dim oItem
For Each oItem in oFolder.Files
strHTML = strHTML & "File: " & oItem.Name & "<br>"
Next

For Each oItem in oFolder.SubFolders
strHTML = strHTML & "Folder: " & oItem.Name & "<br>"
Call GetSubFolders( oItem )
Next
On Error GoTo 0
End Sub

Sub Clear_Form()
Location.Reload(True)
End Sub
Sub HTA_Close()
self.close()
End Sub
</script>
<hta:application
applicationname="Template"
border="dialog"
borderstyle="normal"
caption="Template"
contextmenu="yes"
icon="no.ico"
maximizebutton="yes"
minimizebutton="yes"
navigable="yes"
scroll="yes"
selection="yes"
showintaskbar="yes"
singleinstance="yes"
sysmenu="yes"
version="1.0"
windowstate="normal"
>
</head>
<body>
<center>
<!-- <img src="[link=file://SERVER/SHARE/My_Logo.jpg]file://SERVER/SHARE/My_Logo.jpg[/link]" alt="Company Logo"> -->
<h3>Template</h3>
<hr width="90%">
<br>
<select id="drp_Drives" size="1">
<option>All</option>
</select>
<br>
<br>
<button class="button" id="btn_DoIt" title="Run Report...">Run Report</button>
<br>
<br>
<span id="spn_Status"></span>
</center>
</body>
</html>

How to build this VBscript into a HTA ?

Posted: Wed Jun 01, 2011 3:36 am
by jvierra
Here is a link to the thread where we discussed this a month ago:

http://www.scriptinganswers.com/forums/ ... p?TID=4410

There are more links to examples uf using an HTA to list files.

How to build this VBscript into a HTA ?

Posted: Wed Jun 01, 2011 6:34 am
by hackoo
To be sure I went back and reviewed 'ListFiles.hta'.  It does everything you are asking for.  You can select any drive or folder and specify an extension and it will list all files that match.  This is what you orifginally asked for.
 
 
Yes you have right i will look on it because on the last time i have some trouble to download it but now it's ok Thank you very much for your help and for your HTA Examples !