Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 

Recommended Posts


I am looking for an hta which can scan a certain folder for exe/msi files, list them with radio-buttons, so that you can select multiple applications to install.

Then once selection is made, the script will run each selected application's exe or msi file, silently with no reboot. If this is even possible with different applications, and a mixture of exe and msi files. The silent install is optional, it does not have to be silent, some form of progress bar or something would be nice.

My scripting skills are closely to non-existent, and I have been googling myself silly, and most topics that I come across is related to SCCM 2007 or MDT, and I don't want to use any of those programs.

Any help with this would be highly appreciated.

oooo ok, some luck... found a vbs script that scans a folder and then shows you all the files in a popup message.

Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "D:\Shared\Applications\Unsorted"

Set objFolder = objFSO.GetFolder(objStartFolder)
Wscript.Echo objFolder.Path
Set colFiles = objFolder.Files
For Each objFile in colFiles
Wscript.Echo objFile.Name

ShowSubfolders objFSO.GetFolder(objStartFolder)

Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Wscript.Echo Subfolder.Path
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
Wscript.Echo objFile.Name
ShowSubFolders Subfolder
End Sub

Now just to figure out how to get that into a hta file, with radio buttons next to each file. I guess some form of loop should do the trick.

Edited by MadFly1

Share this post

Link to post
Share on other sites

I'm not sure that searching for EXEs and MSIs is the way to go. I use a "control file" to determine what is listed and executed. For example, an INI or XML file. So you have the paths to your applications stored in the INI file, which you can change just the INI to show different options over time. I use this INI trick to control my app installer, which is an EXE that is in WinPE, and the INI file is on the server.

Also, I'm sure you meant it but you need Checkboxes for multiple selection, as radio buttons are for single selection.

Moving to appropriate forum.

Share this post

Link to post
Share on other sites

Here is a better recursive script. I have it list all the files in a text file, the text file open

automatically after the script has list all files. After you close the text file it will ask if you

want to keep the file or delete the file.

Demo Recursive List Script

'-> Object For Run Time
Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
'-> Variables For Run Time
Dim Col, Ln, Obj, Ts, Tx
Ln = "--------------------------------------------------------------"
Tx = Act.SpecialFolders("Desktop") & "\ListFiles.txt"
'-> Create Text File
Set Ts = Fso.CreateTextFile(Tx)
Ts.WriteLine " Time : " & Time()
Ts.WriteLine " Date : " & Date()
Ts.WriteLine Ln
'-> Start The Listing Of All Files In All Sub Folders
'-> Close Text File
'-> Read The Text File
'-> Ask To Keep Or Delete File
If MsgBox("Did you want to keep the text file", _
4132,"Keep Or Delete") = 7 Then Fso.DeleteFile(Tx),True

'-> Recursive
Function Recursive(Folder)
Ts.WriteLine " Folder Name : " & Folder
Ts.WriteLine Ln
'-> List Files In Folder
For Each Obj In Folder. Files
Ts.WriteLine " File Name : " & Obj.Name
Ts.WriteLine " File Path : " & Obj.Path & vbCrLf
'-> Goes Threw All Sub Folders In Parent Folder
For Each Col In Folder.SubFolders
Ts.WriteLine Ln
End Function

Share this post

Link to post
Share on other sites

Thank you for the replies.

I kind of like the ini idea Tripredacus mentioned, however, I don't think it is what I am after.

Ideally, I would like to be able to copy all the necessary exe install files of the apps that I might need to a specific folder, and have an hta file somewhere on the network, so that if I reinstalled or applied a image to a user's computer, after the imaging, I can open the hta file, and install the application nice and easy off this list. All that then needs modifying is the exe files should be replaced as new versions are available.

As I said, the silent install thing is a total optional thing, would be nice, but not necessary at all, if I can just get the list generated, and clickable to open the file and run the exe, that would also be good.

I found this script somewhere else, it's close to what I want. I added the radio button thing, but it does not select anything, and if the select works, then at the bottom there should be a button which says install or something. And without the browse for folder would be the best ever, if I was able to set a static folder, I tried changing "Select The Folder To Enumerate" line to D:\shared\applications\, but then it just gives an error, or statement needed or missing.

<Title>Application Options</Title>

Caption = Yes
Border = Thick
ShowInTaskBar = No
MaximizeButton = Yes
MinimizeButton = Yes>

<script Language = VBScript>
Sub WindowsLoad
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder (0, "Select The Folder To Enumerate :", (0))
If objFolder Is Nothing Then
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
End If

Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(objPath)
For each objFile in objFolder.Files
If objFolder.Files.Count > 0 Then
Window.Document.Title = "Information For " & objPath
strHtml = strHtml & "<td><Font color = Blue><input type='radio' value='filename'>" & objFile.Name & "</font></Br>"
DataArea.InnerHtml = strHtml
End If
End Sub


<p><h3 align = center><font color='Orange'>Application Options</font></h3></p>


<input Type="Button" Value="Browse For Folder" Name="Run_Button" onClick="WindowsLoad"><p></td>

<Span Id="DataArea"></Span><Div Align = "Center">
<input Type="Button" Value="Install">

Edited by MadFly1

Share this post

Link to post
Share on other sites

Since I will not be doing your job, here is a hta that makes 20 checkboxes on a onload event.

Each checkbox returns a simple message box, this is coded in Jscript but it will show how to

add active checkboxes by script.


Script By Gunsmokingman Aka Jake1eye
<TITLE>Script Make Checkboxes</TITLE>
<STYLE type="text/css">
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
Border-Top:0px Transparent;
Border-Bottom:0px Transparent;
Border-Left:0px Transparent;
Border-Right:0px Transparent;
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
Border-Left: 1px Transparent;
Border-Right: 2px Transparent;
Border-Top: 1px Transparent;
Border-Bottom: 2px Transparent;
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
<script LANGUAGE='JScript'>
//-> Resize And Place In Approx center
var c34=String.fromCharCode(34),C1=0,X1,Y1;
//-> OnLoad
window.onload=function(){CbxArea.style.visibility = "";MakeCheckBox();}
//-> Make 20 Checkboxes 2 x 10 Colums
function MakeCheckBox(){ X1=1;Y1=30;
for(var i=0; i < 20; i++){
var Cbx ="<TABLE Style='Position:Absolute;Top:"+X1+"pt;Left:"+Y1+"pt;'>"+
"<TD OnMouseOver=';' OnMouseOut='' "+
"Class='C1'>Checkbox "+AZero(C1,2)+"</TD><TD Class='C2'>"+
"<Input Type='CheckBox' Name='CBX' ID='C_B_X_"+AZero(C1,2)+"'"+
" Value='Checkbox'"+AZero(C1,2)+" OnClick='alert("+c34+
"Checkbox "+AZero(C1,2)+c34+")'></Input></TD></TABLE>"
/* */
if(C1==10 && C1 <=11){ChkAdd(Cbx);X1=1,Y1=145}else{ChkAdd(Cbx)}
//-> Build Checkboxes
function ChkAdd(C){CbxArea.innerHTML = C+CbxArea.innerHTML;}
//-> Add Zero To A Number
function AZero(N,T){if(T==2){ //-> EG 1 = 01
if(N <= 9){N="0"+N} if(N == 10){N=N}}
if(T==3){ //-> EG 1 = 001
if(N <= 9){N="0"+N} if(N == 10){N=N}
if(N <= 99){N="0"+N} if(N == 100){N=N}}
return N;}
<DIV ID='CbxArea' Style='Height:80pt;Width:352pt;visibility:hidden;
Position:Absolute;Top:12;Left:12;'> </DIV>

Share this post

Link to post
Share on other sites

Thank very much for that script, it should keep me busy for quite some time.

In the mean time I came across this script, and with a little modification here and there (mostly styling) it is exactly what I was looking for.


<title>Application Options</title>

Caption = Yes
Border = Thick
ShowInTaskBar = No
MaximizeButton = No
MinimizeButton = No

<script Language="VBScript">

Dim sTemplates, oWSHShell ' global variable

sub window_onload
Dim file, oAnchor ' local variable

set oWSHShell = CreateObject("WScript.Shell")
' With the line below we specify which folder to scan for files
sTemplates = oWSHShell.expandenvironmentstrings("D:\Shared\Applications\List") _
' & "\AppData\Roaming\Microsoft\Templates\"

with CreateObject("Scripting.FileSystemObject")
for each file in .getfolder(sTemplates).Files
set oAnchor = document.createElement("A")
oAnchor.href = file.Path
oAnchor.innerText = file.name & vbcrlf
oAnchor.onclick = GetRef("Launch")
next ' files
end with ' FileSystemObject
end sub
sub Launch
with window.event
.cancelBubble = true
.returnvalue = false
oWSHShell.run chr(34) & .srcElement.href & chr(34), 1, False
end with
end sub


sub DoResize
window.resizeTo 600,800
screenWidth = Document.ParentWindow.Screen.AvailWidth
screenHeight = Document.ParentWindow.Screen.AvailHeight
posLeft = (screenWidth - 600) / 2
posTop = (screenHeight - 800) / 2
'move to centerscreen
window.moveTo posLeft, posTop
end sub

DoResize() ' run the subroutine to position the containing window (your HTA dialog) before the body is rendered.


<span id=list></span>


Found it on some social Microsoft blog thing... Social Technet

I really hope I am not infringing on any copyright or any forum rules by posting it here. :)


Edited by MadFly1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.