Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Software Install HTA

- - - - -

  • Please log in to reply
5 replies to this topic

#1
MadFly1

MadFly1
  • Member
  • 7 posts
  • Joined 31-May 13
  • OS:Windows 7 x64
  • Country: Country Flag
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, 14 June 2013 - 04:42 AM.



How to remove advertisement from MSFN

#2
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 10,005 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

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.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
tpxmsfn1_zps393339c1.jpg

#3
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,430 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
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 



GunSmokingMan



#4
MadFly1

MadFly1
  • Member
  • 7 posts
  • Joined 31-May 13
  • OS:Windows 7 x64
  • Country: Country Flag
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, 14 June 2013 - 04:00 PM.


#5
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,430 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
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.
Attached File  DemoCheckBoxes.png   118.64KB   8 downloads

<!--
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> 



GunSmokingMan



#6
MadFly1

MadFly1
  • Member
  • 7 posts
  • Joined 31-May 13
  • OS:Windows 7 x64
  • Country: Country Flag
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. :)

Attached Files


Edited by MadFly1, 14 June 2013 - 05:13 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users