• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
MadFly1

Software Install HTA

6 posts in this topic

Hi

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
Next
Wscript.Echo

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
Next
Wscript.Echo
ShowSubFolders Subfolder
Next
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
0

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.

0

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
Recursive(Fso.GetFolder("."))
'-> Close Text File
Ts.Close
'-> Read The Text File
Act.Run(Tx),1,True
'-> 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
Next
'-> Goes Threw All Sub Folders In Parent Folder
For Each Col In Folder.SubFolders
Ts.WriteLine Ln
Recursive(Col)
Next
End Function

0

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.


<html>
<Head>
<Title>Application Options</Title>

<HTA:Application
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
Wscript.Quit
Else
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
Next
End Sub

</Script>
<body>

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

<div></div>

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

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

Edited by MadFly1
0

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.

post-5386-0-55972600-1371247806_thumb.pn


<!--
Script By Gunsmokingman Aka Jake1eye
June-14-2013
-->
<TITLE>Script Make Checkboxes</TITLE>
<STYLE type="text/css">
Body
{
Font-Size:9.25pt;
Font-Weight:Bold;
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
Color:Black;
BackGround-Color:#EFE9E3;
Margin-Top:5;
Margin-Bottom:5;
Margin-Left:4;
Margin-Right:4;
Padding-Top:1;
Padding-Bottom:1;
Padding-Left:4;
Padding-Right:4;
Text-Align:Left;
Vertical-Align:Top;
Border-Top:0px Transparent;
Border-Bottom:0px Transparent;
Border-Left:0px Transparent;
Border-Right:0px Transparent;
}
BUTTON
{
Height:13pt;
width:65pt;
Font:8.05pt;
Font-weight:bold;
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
Color:#292929;
Text-Align:Center;
Vertical-Align:Middle;
filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorStr='#E5E5E5',EndColorStr='#7D7D7D');
Margin:1;
Padding:1;
Border-Left: 1px Transparent;
Border-Right: 2px Transparent;
Border-Top: 1px Transparent;
Border-Bottom: 2px Transparent;
}
.HighLight
{
Font-Size:8.05pt;
Font-weight:bold;
Color:#000043;
filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorStr='aliceblue',EndColorStr='#239595');
}
.BLight
{
Font-Size:8.05pt;
Font-weight:bold;
Color:#411141;
filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorStr='#006363',EndColorStr='#BAEABA');
}
TD
{
Font-Size:8.05pt;
Font-Weight:Bold;
Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;
Color:Black;
}
TD.C1{Width:81PT;}
TD.C2{Width:14PT;}
</STYLE>
<script LANGUAGE='JScript'>
//-> Resize And Place In Approx center
window.resizeTo(515,325)
window.moveTo(screen.availWidth/2-(515/2),screen.availHeight/2-(325/2))
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++){
C1+=1;
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>"
X1=X1+20;
/* */
if(C1==10 && C1 <=11){ChkAdd(Cbx);X1=1,Y1=145}else{ChkAdd(Cbx)}
if(C1>=11){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;}
</SCRIPT>
<BODY>
<DIV ID='CbxArea' Style='Height:80pt;Width:352pt;visibility:hidden;
Position:Absolute;Top:12;Left:12;'> </DIV>
</BODY>

0

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.



<html>
<head>

<title>Application Options</title>

<HTA:Application
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")
list.appendChild(oAnchor)
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

</script>

</head>
<script>
sub DoResize
'resize
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.

</script>
<body>

<span id=list></span>

</body>
</html>

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. :)

post-378622-0-93139500-1371251612_thumb.

Edited by MadFly1
0

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.