troubleshooting Question

Install Software through HTA. Need to set permission

Avatar of bsharath
bsharathFlag for India asked on
Programming Languages-OtherVisual Basic ClassicScripting Languages
28 Comments1 Solution5152 ViewsLast Modified:
Hi,

below is a Software install HTA. That is done by Rob.

I have a senario. Where the shared folder where all these softwares are there does not have permissions for the user.
So as the helpdesk engineer connects to the users machine through MSTSC. Browses to this HTA file where every one has permissions.
Then there need to be a box which shall ask the username and password. After which the installer. Put in the credentials to install softwares on the restricted share with these new credentials.
Any help is of great use...
Regards
Sharath
'=============
<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(_
           "Chennai;Office Products;Office 2003;\\in\FS\Office_Products\Office_2003\SETUP.EXE", _
           "Chennai;Office Products;Office Xp;\\dev\Office XP\SETUPPRO.EXE", _
            "Chennai;Utilities;WinZip;\\dev\WinZip\SETUP.EXE", _
            "Chennai;Utilities;Adobe Reader 7;\\ntfp\software\Adobe Reader\AdobeRdr709_Extracted\Adobe Reader 7.0.9.msi", _
            "Chennai;Utilities;Windows Installer 3;\\ntfp\software\Windows Installer 3.1\WindowsInstaller-KB893803-v2-x86.exe", _
            "Hyderabad;Messengers;Windows Messenger;\\server\share\WinMessenger\setup.exe", _
            "Hyderabad;Utilities;Security Test;\\server\share\temp\PS4LICENSE\setup.exe", _
            "Hyderabad;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>
'=============
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 28 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 28 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros