/build/static/layout/Breadcrumb_cap_w.png

Using HTA to install applications SCCM 2012

Good morning

 

I'm wondering if someone might be able to help. We have an HTA that we use to deploy our application sets. Previously we ran the HTA referencing the installation paths as UNC from the network. However our new SCCM 2012 deployment requires us to now use relative paths when deploying apps, as we deploy the entire source locally and execute the app that way.

I wrote a script which i amended to do just this in wscript however HTA doesn't support wscript shell, or atleast i'm not quite sure how to call it.

I'm hoping someone here can help me out to amend my script to use objShell instead.

 

Below is an extract from my working script

Dim App1
Dim App2
StrApp1 = "Java_7_Update_17"
strApp2 = "Adobe_Player_11"
Set sho = Wscript.CreateObject("Wscript.Shell") 
            strCurrentDir = Left(Wscript.ScriptFullName, (InstrRev(Wscript.ScriptFullName, "\") -1)) & "\"

           strCommandToRun = chr(34) & strCurrentDir & strApp1 & "\Install2.cmd"

           Java = sho.run(strCommandToRun,1,True)

           strCommandToRun = chr(34) & strCurrentDir & strApp1 & "\Install2.cmd"

           Flash = sho.run(strCommandToRun,1,True)


And this is the extract trying to covert it into my HTA - keep getting a Wscript error every time i try to import the above script.

Dim App0
Dim App1
Dim App2
Dim App3
Dim App4
Dim App5
Dim App6
Dim App7
Dim App8

'Set You Application folder Name

StrApp0 = "HTA"
StrApp1 = "Java_7_Update_17"
strApp2 = "Silverlight_5.1.20.125.0"
strApp3 = "Adobe_Reader_11.02"
strApp4 = "Adobe_FlashPlayer_Active_X_11"
strApp5 = "Microsoft_Lync_2010"
strApp6 = "Citrix_OfflinePlugIn_6.7.0.10.27"
strApp7 = "Citrix_OnlinePlugin_12.3.0.8"
strApp8 = "Visual_C++_Redistributable_2010"



'*********************************************************************************
' DO NOT EDIT These lines, expanded installation path variable

    strCurrentDir = Left(objShell.CurrentDirectory, (InstrRev(objShell.CurrentDirectory, "\") -1)) & "\"
'*********************************************************************************

'Run SMSDeploymentPage_Reboot.hta           
    strCommandToRun = chr(34) & strCurrentDir & strApp0 & "SMSDeploymentPage_Reboot.hta"
    
    HTA = objShell.Run(strCommandToRun)


' Format for MSI installation of application strCommandToRun = chr(34) & strCurrentDir & "xxx.msi" & chr(34) & " /quiet /norestart" 
' Format for CMD installation of application strCommandToRun = chr(34) & strCurrentDir & strApp1 & "\Install.cmd" 

'Only amend application Name prefix <app> = sho.run(strCommandToRun,1,True)

        strCommandToRun = chr(34) & strCurrentDir & strApp1 & "\Install2.cmd"
        Java = sho.run(strCommandToRun,1,True)   
        
        strCommandToRun = chr(34) & strCurrentDir & strApp2 & "\Install2.cmd"    
        Silverlight = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp3 & "\Install2.cmd"
        AdobeReader = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp4 & "\Install2.cmd"
        AdobeFlashPlayer = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp5 & "\Install2.cmd"
        MicrosoftLync2010 = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp6 & "\Install2.cmd"
        CitrixOfflinePlugIn = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp7 & "\Install2.cmd"
        CitrixOnlinePlugIn = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp8 & "\Install2.cmd"
        C++Redistributable2010 = sho.run(strCommandToRun,1,True)


If anyone could Help i would be most appreciative, I have been racking my brain with my limited vbscript experience.


0 Comments   [ + ] Show comments

Answers (6)

Posted by: jagadeish 11 years ago
Red Belt
2

'Run SMSDeploymentPage_Reboot.hta           
    strCommandToRun = chr(34) & strCurrentDir & strApp0 & "\SMSDeploymentPage_Reboot.hta" & Chr(34)
    
    HTA = objShell.Run(strCommandToRun)


' Format for MSI installation of application strCommandToRun = chr(34) & strCurrentDir & "xxx.msi" & chr(34) & " /quiet /norestart" 
' Format for CMD installation of application strCommandToRun = chr(34) & strCurrentDir & strApp1 & "\Install.cmd" 

'Only amend application Name prefix <app> = sho.run(strCommandToRun,1,True)

        strCommandToRun = chr(34) & strCurrentDir & strApp1 & "\Install2.cmd" & Chr(34)

        Java = sho.run(strCommandToRun,1,True)   
        
        strCommandToRun = chr(34) & strCurrentDir & strApp2 & "\Install2.cmd" & Chr(34)

        Silverlight = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp3 & "\Install2.cmd" & Chr(34)

        AdobeReader = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp4 & "\Install2.cmd" & Chr(34)

        AdobeFlashPlayer = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp5 & "\Install2.cmd" & Chr(34)

        MicrosoftLync2010 = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp6 & "\Install2.cmd" & Chr(34)

        CitrixOfflinePlugIn = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp7 & "\Install2.cmd" & Chr(34)

        CitrixOnlinePlugIn = sho.run(strCommandToRun,1,True)
        
        strCommandToRun = chr(34) & strCurrentDir & strApp8 & "\Install2.cmd" & Chr(34)

        C++Redistributable2010 = sho.run(strCommandToRun,1,True)

Posted by: asman 11 years ago
Purple Belt
1

Why use a HTA?

SCCM: Create a package for each application instead of multi install, you just have to point out your install2.cmd(or install.vbs or just run commandline directly, ex: msiexec.exe /qn /i "some_program.msi")....let SCCM reboot client if needed, same story with cache/Run from UNC


Comments:
  • With addtional notes to Asman, I recommened using the msiexec cmd if possible, it chats better SCCM, ie it will resport pending reboots etc, ie you will have better status knowledge over a cmd which is either a 0 or sucess or 1 for fail. Hope you get what I mean. R. - rileyz 11 years ago
Posted by: djjass 11 years ago
Senior Purple Belt
1

Thanks for all the replies. We need to USA an HTA as we want to display a large window that locks the users out of the computer while the updates happen silently in the background. We are installing Citrix plugins, java, killing IE, Citrix ect all from the HTA.

I think i'm close now to have it working, if i get some further ill post my results tomorrow hopefully help someone out.


Comments:
  • SCCM's feature: Program can run: "Only when NO user is logged on".

    However, i understand what u are getting at...there is always a small percentage of users that slips through (when the condition "no users" is passed...the installation starts and in the exact same time a user loggs on and starts a application that's being upgraded/uninstalled etc etc...and it fails).

    I guess you are making something like this?
    http://anotherblabla.wordpress.com/2012/02/29/sccm-allow-users-to-postpone-deployment-updated-script/

    In the enviroment im currently in...we use SCCM, have a basic vbscript template for installation with some additional functions that SCCM dosent have. And if we need to alert the user that something's going to happen,we use a 3rd party software (explaining that a installation is going to happen, a reboot needs to be done and so on..) with a postpone option. This 3rd party software is just a .exe (executed from the vbscript, in the start or end depending on application). - asman 11 years ago
Posted by: anonymous_9363 11 years ago
Red Belt
1

Remove the 'WScript.' directive. That is, make 'Wscript.CreateObject' become just 'CreateObject'. The directive refers the script to the WScript interpreter (let's call it) which doesn't exist in the HTA namespace.

Note, however, that - confusingly - WScript runtime objects require the prefix because they refer to registered objects. So, you'll need to still have (things like) 'CreateObject("WScript.Shell")'.

Posted by: djjass 11 years ago
Senior Purple Belt
1

thanks for all the replies guys, managed to get it working. Feel free to use this code if you have the same problem as i did going forward. Essentially my main HTA (code below) executes all the installations with a coundown. It also calls a secondary HTA which locks out the entire screen resolution which prevents the end user from touching anything during a deploy. You can use the code below just enter it into the <Script language> section of the HTA.

Change your paths as needed.

<SCRIPT Language="VBScript">

Dim StrCounting

 

 

Sub Window_OnLoad

   ' Resize the window

    self.Focus()

    self.ResizeTo 760,510

    'StrCounting = 90

    StrCounting = 3

    BasicTextBox.Value = StrCounting

    iTimerID = window.setInterval("RunScript", 1000, "VBScript")

End Sub

 

Sub RunScript

    StrCounting = StrCounting - 1

    BasicTextBox.Value = StrCounting

    If StrCounting = 0 Then

 

 ' Set variables

 Dim objWshShell

 Dim sho

 Dim fso

    Set WshShell = CreateObject("WScript.Shell")

    Set oShell = CreateObject("WScript.Shell")

    Set oEnv = oShell.Environment("PROCESS")

Set objShell = CreateObject("Wscript.shell")

Set objEnv = objShell.Environment("PROCESS")

'Set ofso = Createobject("Shell.Application")

Set fso = CreateObject("Scripting.FileSystemObject")

 

'*********************************************************************************

 

'Main Routine - Set NOZONECHECKS for Open file security

 

'*********************************************************************************

 

 

objEnv("SEE_MASK_NOZONECHECKS") = 1

 

'USE TO CLOSE DOWN ANY APPLICTIONS THAT MAY HAVE BEEN LEFT OPEN

 

'Close down Internet Explorer

objShell.Run("taskkill.exe /F /IM iexplore.exe"), 1, True

 

'Close Microsoft Lync

objShell.Run("taskkill.exe /F /IM communicator.exe"), 1, True

 

'Close Citrix Online Plugin

objShell.Run("taskkill.exe /F /IM Pnamain.exe"), 1, True

 

'Close Citrix Off-line Plugin

objShell.Run("taskkill.exe /F /IM RadeObj.exe"), 1, True

objShell.Run("taskkill.exe /F /IM wfcrun32.exe"), 1, True

objShell.Run("taskkill.exe /F /IM concentr.exe"), 1, True

 

'*********************************************************************************

 

'Install Applications 

 

'*********************************************************************************

 

'Run SMSDeploymentPage_Reboot.hta

'Set You Application Dim's

 

Dim App0

Dim App1

Dim App2

Dim App3

Dim App4

Dim App5

Dim App6

Dim App7

Dim App8

 

'Set You Application folder Name

 

StrApp0 = "HTA"

StrApp1 = "\Java_7_Update_17"

strApp2 = "\Silverlight_5.1.20.125.0"

strApp3 = "\Adobe_Reader_11.02"

strApp4 = "\Adobe_FlashPlayer_Active_X_11"

strApp5 = "\Microsoft_Lync_2010"

strApp6 = "\Citrix_OfflinePlugIn_6.7.0.10.27"

strApp7 = "\Citrix_OnlinePlugin_12.3.0.8"

strApp8 = "\Visual_C++_Redistributable_2010"

 

 

 

'*********************************************************************************

' DO NOT EDIT These lines, expanded installation path variable

'

'*********************************************************************************

 

'Run SMSDeploymentPage_Reboot.hta

strCommandToRun = fso.GetAbsolutePathName (".") & "\SMSDeploymentPage_Reboot.hta"

    objShell.Run Chr(34) & strCommandToRun

 

 

' Format for MSI installation of application strCommandToRun = chr(34) & strCurrentDir & "xxx.msi" & chr(34) & " /quiet /norestart" 

' Format for CMD installation of application strCommandToRun = chr(34) & strCurrentDir & strApp1 & "\Install.cmd" 

 

'Only amend application Name prefix <app> = sho.run(strCommandToRun,1,True)

 

strCommandToRun = fso.GetAbsolutePathName (".") & strApp1 & "\Install2.cmd"

objShell.Run Chr(34) & strCommandToRun, 1, True

 

strCommandToRun = fso.GetAbsolutePathName (".") & strApp2 & "\Install2.cmd"

objShell.Run Chr(34) & strCommandToRun, 1, True

 

strCommandToRun = fso.GetAbsolutePathName (".") & strApp3 & "\Install2.cmd"

objShell.Run Chr(34) & strCommandToRun, 1, True

 

strCommandToRun = fso.GetAbsolutePathName (".") & strApp4 & "\Install2.cmd"

objShell.Run Chr(34) & strCommandToRun, 1, True

 

strCommandToRun = fso.GetAbsolutePathName (".") & strApp5 & "\Install2.cmd"

objShell.Run Chr(34) & strCommandToRun, 1, True

 

strCommandToRun = fso.GetAbsolutePathName (".") & strApp6 & "\Install2.cmd"

objShell.Run Chr(34) & strCommandToRun, 1, True

 

strCommandToRun = fso.GetAbsolutePathName (".") & strApp7 & "\Install2.cmd"

objShell.Run Chr(34) & strCommandToRun, 1, True

 

strCommandToRun = fso.GetAbsolutePathName (".") & strApp8 & "\Install2.cmd"

objShell.Run Chr(34) & strCommandToRun, 1, True

 

'DO NOT EDIT ANY LINES BELOW HERE

 

'Tattoo MOE Update Date and Time - HKLM\CSR\Revision and HJKLM\CSR\Revision Date

strCommandToRun = fso.GetAbsolutePathName(".") & "\DateTime.vbs"

objShell.Run Chr(34) & strCommandToRun, 1, True

'*********************************************************************************

 

'Finished Application Installations Reboot machine

 

'*********************************************************************************

 

'Enable UAC

objShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f", 1, True

 

 

'*********************************************************************************

 

'Set Clean up task post Reboot

'objShell.Run "REG.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEX /v DelHTARunOnce /t REG_QWORD /d 2 /f", 1, True

'objShell.Run "REG.exe IMPORT C:\CSR_Logs\HTARunOnce.reg", 1, True

'objShell.Run "cmd /c DEL /F /Q C:\CSR_Logs\DelHTARunOnce.reg", 1, True  

 

'*********************************************************************************

'Reboot machine in 60 seconds

objShell.Run "shutdown.exe /R /T 5 /C """ & "CSR MOE Update Complete. Rebooting your computer now!"""  

'*********************************************************************************

 

'Finished Application Installations 

 

'*********************************************************************************

 

 

objEnv.Remove("SEE_MASK_NOZONECHECKS")

 

   Window.Close()

  End IF 

End Sub 

 

'*********************************************************************************

 

'Log Custom event -> Set new Variable for WShell

 

'*********************************************************************************

'Start logging

Dim objWshShell 

Set objWshShell = CreateObject("WScript.Shell") 

objWshShell.LogEvent 4, "MOE Update 1 detected reboot required - restarting the computer." 

</SCRIPT>

</html>

 

Posted by: anonymous_9363 11 years ago
Red Belt
0

Lots of unnecessary duplicate code there. Try this for defining the app list:

Dim strApp
Dim strAppList
Dim arrAppList
Dim intAppIndex

strAppList = ""
strAppList = strAppList & "HTA,"
strAppList = strAppList & "\Java_7_Update_17,"
strAppList = strAppList & "\Silverlight_5.1.20.125.0,"
strAppList = strAppList & "\Adobe_Reader_11.02,"
strAppList = strAppList & "\Adobe_FlashPlayer_Active_X_11,"
strAppList = strAppList & "\Microsoft_Lync_2010,"
strAppList = strAppList & "\Citrix_OfflinePlugIn_6.7.0.10.27,"
strAppList = strAppList & "\Citrix_OnlinePlugin_12.3.0.8,"
strAppList = strAppList & "\Visual_C++_Redistributable_2010"

If Right(strAppList, 1) = "," Then
    '// Oops! You left in a trailing comma!
    strAppList = Left(strAppList, Len(strAppList) - 1)
End If

'// Create an array from the app list, using comma as the delimiter
arrAppList = Split(strAppList, ",")

And then for the execution part:

For intAppIndex = 0 To UBound(arrAppList)
    strApp    = arrAppList(intAppIndex)
    strCommandToRun = fso.GetAbsolutePathName (".") & strApp & "\Install2.cmd"

    objShell.Run Chr(34) & strCommandToRun & Chr(34), 1, True
    '// Personally, I would add a check here for installation success or failure
    '// If blnSuccess Then
    '//    ' Write to a log - the Event Log, maybe
    '// End If
Next

Now, when the app list changes, all you need to do is edit the strAppList string! :-)


Comments:
  • nice thank you :) still learning my way through scripting - djjass 11 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ