asked on
'=============
<head>
<title>Choose Software To Install</title>
<HTA:APPLICATION
APPLICATIONNAME="Choose Software To Install"
BORDER="thin"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
</head>
<script language="VBScript">
Dim arrSoftware
Sub Window_onLoad
intWidth = 800
intHeight = 600
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
arrSoftware = Array(_
"Lucknow;Office Products;Office 2003;\\dsm\Lucknow_FS\Office_Products\Office_2003\SETUP.EXE", _
"Lucknow;Office Products;Office Xp;\\dsm\Lucknow_FS\Office_Products\Office XP\SETUPPRO.EXE", _
"Lucknow;Office Products;Office 97;\\dsm\Lucknow_FS\Office_Products\OFFICE97\SETUP.EXE", _
"Lucknow;Office Products;One Note 2003;\\dsm\Lucknow_FS\Office_Products\ONE NOTE 2003\SETUP.EXE", _
"Lucknow;Office Products;BIZ Talk Server 2004;\\dsm\Lucknow_FS\Office_Products\BIZ Talk Server 2004 DEV\SETUP.EXE", _
"Lucknow;Office Products;Compatibility Pack for Office 2007 ;\\dsm\Lucknow_FS\Office_Products\Compatibility Pack for 2007 formats\FileFormatConverters.exe /quiet", _
"Lucknow;Office Products;Office 2000 Standard;\\dsm\Lucknow_FS\Office_Products\Office 2000 Standard\SETUP.EXE", _
"Lucknow;Office Products;Visio 2003;\\dsm\Lucknow_FS\Office_Products\Visio\VISIO2003\SETUP.EXE", _
"Lucknow;Office Products;Front Page 2003;\\dsm\Lucknow_FS\Office_Products\MS Office FP 2003\SETUP.EXE", _
"Lucknow;Utilities;WinZip;\\dev-chen-mrd100\WinZip\SETUP.EXE", _
"Lucknow;Utilities;Adobe Reader 7;\\ntfp\software\Adobe Reader\AdobeRdr709_Extracted\Adobe Reader 7.0.9.msi", _
"Lucknow;Utilities;Windows Installer 3;\\ntfp\software\Windows Installer 3.1\WindowsInstaller-KB893803-v2-x86.exe", _
"Munnar;Messengers;Windows Messenger;\\server\share\WinMessenger\setup.exe", _
"Munnar;Utilities;Security Test;\\server\share\temp\PS4LICENSE\setup.exe", _
"Munnar;Databases;SQL Server Tools;\\server\share\SQL Server\Tools\setup.exe")
Populate_Office
End Sub
Sub Populate_Office
strHTML = "<select size='1' name='cbo_office' onchange='vbs:Populate_SoftwareType'>" & VbCrLf
strHTML = strHTML & "<option selected value='cbo_office'> --- Select Office --- </option>" & vbCrLf
strOffices = ";"
For Each strProduct In arrSoftware
strOffice = Split(strProduct, ";")(0)
If InStr(LCase(strOffices), LCase(";" & strOffice & ";")) = 0 Then
strOffices = strOffices & strOffice & ";"
strHTML = strHTML & "<option value='" & strOffice & "'>" & strOffice & "</option>" & VbCrLf
End If
Next
strHTML = strHTML & "</select>"
span_office.InnerHTML = strHTML
End Sub
Sub Populate_SoftwareType
strHTML = "<select size='1' name='cbo_softwaretype' onchange='vbs:Populate_Application'>" & VbCrLf
strHTML = strHTML & "<option selected value='cbo_softwaretype'> --- Select Software Type --- </option>" & VbCrLf
strTypes = ";"
For Each strProduct In arrSoftware
If LCase(Split(strProduct, ";")(0)) = LCase(cbo_office.Value) Then
strType = Split(strProduct, ";")(1)
If InStr(LCase(strTypes), LCase(";" & strType & ";")) = 0 Then
strTypes = strTypes & strType & ";"
strHTML = strHTML & "<option value='" & strType & "'>" & strType & "</option>" & VbCrLf
End If
End If
Next
strHTML = strHTML & "</select>"
span_softwaretype.InnerHTML = strHTML
End Sub
Sub Populate_Application
strHTML = "<select size='1' name='cbo_application'>" & VbCrLf
strHTML = strHTML & "<option selected value='cbo_application'> --- Select Application --- </option>" & VbCrLf
For Each strProduct In arrSoftware
If LCase(Split(strProduct, ";")(0)) = LCase(cbo_office.Value) And LCase(Split(strProduct, ";")(1)) = LCase(cbo_softwaretype.Value) Then
strApplication = Split(strProduct, ";")(2)
strFilePath = Split(strProduct, ";")(3)
strHTML = strHTML & "<option value='" & strApplication & ";" & strFilePath & "'>" & strApplication & "</option>" & VbCrLf
End If
Next
strHTML = strHTML & "</select>"
span_application.InnerHTML = strHTML
End Sub
Sub Default_Buttons
If Window.Event.KeyCode = 13 Then
btn_install.Click
End If
End Sub
Sub Install_Software
strLogFile = "\\indiasophos\Ps\HTA_Install_Log.csv"
Const intForAppending = 8
If cbo_office.Value = "cbo_office" Then
MsgBox "Please select an office."
cbo_office.Focus
ElseIf cbo_softwaretype.Value = "cbo_softwaretype" Then
MsgBox "Please select a software type."
cbo_softwaretype.Focus
ElseIf cbo_application.Value = "cbo_application" Then
MsgBox "Please select an application."
cbo_application.Focus
Else
strProduct = Split(cbo_application.Value, ";")(0)
strExecutable = Split(cbo_application.Value, ";")(1)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
'Software file,Machinename,Username,Date and time
strDetails = strExecutable & "," & objNetwork.ComputerName & "," & objNetwork.UserName & "," & Now
If objFSO.FileExists(strExecutable) = True Then
'objShell.Run strExecutable
If LCase(Right(strExecutable, 4)) = LCase(".msi") Then
strCommand = "msiexec /i " & objFSO.GetFile(strExecutable).ShortPath & " /qf /norestart"
Else
strCommand = "cmd /c """ & objFSO.GetFile(strExecutable).ShortPath & """"
End If
'MsgBox "Installing: " & strProduct & VbCrLf & "From:" & VbCrLf & strExecutable & VbCrLf & "With: " & strCommand
strExitCode = objShell.Run(strCommand, 1, True)
If Left(strCommand, 7) = "msiexec" And strExitCode = 1619 Then
MsgBox "You do not have permission to install this application." & VbCrLf & "Please contact the Help Desk."
ElseIf Left(strCommand, 6) = "cmd /c" And strExitCode = 1 Then
MsgBox "You do not have permission to install this application." & VbCrLf & "Please contact the Help Desk."
End If
Set objOutputFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
objOutputFile.WriteLine strDetails
objOutputFile.Close
Set objOutputFile = Nothing
Else
MsgBox "The file does not exist, or you do not have permission to access it." & VbCrLf & "Please contact the Help Desk."
End If
Set objShell = Nothing
Set objFSO = Nothing
Set objNetwork = Nothing
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align="center" colspan="2">
<h2>Choose Software To Install</h2>
</td>
</tr>
<tr>
<td align='center'>
Choose from the options in each list:
</td>
</tr>
<tr>
<td>
Office:
<span id="span_office">
<select size="1" name="cbo_office">
<option selected value="cbo_office"> --- Select Office --- </option>
</select>
</span>
</td>
</tr
<tr>
<td>
Software Type:
<span id="span_softwaretype">
<select size="1" name="cbo_softwaretype">
<option selected value="cbo_softwaretype"> --- Select Software Type --- </option>
</select>
</span>
</td>
</tr
<tr>
<td>
Application:
<span id="span_application">
<select size="1" name="cbo_application">
<option selected value="cbo_application"> --- Select Application --- </option>
</select>
</span>
</td>
</tr
<tr>
<td align='center' colspan="2">
<input type="button" value="Install" name="btn_install" onClick="vbs:Install_Software"><br><br>
</td>
</tr>
<tr height='20%'>
<td>
</td>
</tr>
</table>
</body>
'=============