<!-- Author Simon Brouillard Fuction Allow user to postpone Installation

-->

<html>

<head>

<title>App Launcher</title>

<HTA:APPLICATION

ID="AppLauncher"

APPLICATIONNAME="AppLauncher"

BORDER="thick"

BORDERSTYLE="raised"

CAPTION="no"

CONTEXTMENU="no"

INNERBORDER="no"

MAXIMIZEBUTTON="no"

MINIMIZEBUTTON="no"

SHOWINTASKBAR="no"

NAVIGATABLE="yes"

SCROLL="no"

SCROLLFLAT="no"

SELECTION="no"

SINGLEINSTANCE="yes"

SYSMENU="no"

WINDOWSTATE="normal"

>

<script language="javascript" type="text/javascript">

function CheckKeys()

 

 {

    function cancel()

     {

     // local function, disable the ATL-F4

        event.keyCode = 0;

        event.cancelBubble = true;

        return false;

     }

   

   

    with(event)

        {

        if(altLeft&&keyCode==115)

        return cancel();

        }

       

     

     

 }

document.onkeydown=CheckKeys;  

</script>

<SCRIPT Language="VBScript">

On Error Resume Next

 

Dim intMinutes

Dim intSeconds

Dim MaxRetry

Dim intLeft

Dim intTop

Dim msiname  

Dim mstname  

Dim logname  

Sub DoResize

'resize

window.resizeTo 525,200

screenWidth = Document.ParentWindow.Screen.AvailWidth

screenHeight = Document.ParentWindow.Screen.AvailHeight

posLeft = (screenWidth - 550) / 2

posTop = (screenHeight - 250) / 2

' move to centerscreen

window.moveTo posLeft, posTop

intMinutes = 5  ' CountDown Value, You also must change it in the HideWindow1, 2, 3 Sub

intSeconds = 0

MaxRetry = 3    ' Nbs of Postpone Allow

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

End Sub

DoResize()

Sub CloseWindow

        If intSeconds = 0 Then

    If intMinutes = 0 Then

                Call StartInstall()

     

    Else

    intMinutes = intMinutes - 1

    End If

    intSeconds = 59

    Else

    intSeconds = intSeconds - 1

    End If

            

Text.innerHTML = intMinutes & " min: " & Right("00" & intSeconds, 2) & " s "

If MaxRetry > 0 Then

        Text2.innerHTML= "If Needed you can postpone the installation " & MaxRetry  & "  time"

Else

        Text2.innerHTML= "You must installed application X Now "

        document.getElementById("btn_run").style.visibility="hidden"

        document.getElementById("opt_script").style.visibility="hidden"

End If

End Sub

Sub Run_Script

        Select Case opt_script.Value

        Case "opt_1"

                HideWindow1

        Case "opt_2"

                HideWindow2

        Case "opt_3"

                HideWindow3

        End Select

End Sub

'''''''''''''''''''

'

' Set the idtimer, intMinutes and intSeconds to match the snooze value you want to allow  

' you must also change it in the option value of the Body part

'  

'''''''''''''''''''

Sub HideWindow1

Set intMinutes = Nothing

Set inSeconds = Nothing

intLeft = window.screenLeft

intTop = window.screenTop

window.moveTo -2000,-2000

idTimer = window.setTimeout("ShowWindow", 1800000, "VBScript")

intMinutes = 35

intSeconds = 0

MaxRetry = MaxRetry - 1

End Sub

Sub HideWindow2

Set intMinutes = Nothing

Set inSeconds = Nothing

intLeft = window.screenLeft

intTop = window.screenTop

window.moveTo -2000,-2000

idTimer = window.setTimeout("ShowWindow", 3600000, "VBScript")

intMinutes = 65

intSeconds = 0

MaxRetry = MaxRetry - 1

End Sub

Sub HideWindow3

Set intMinutes = Nothing

Set inSeconds = Nothing

intLeft = window.screenLeft

intTop = window.screenTop

window.moveTo -2000,-2000

idTimer = window.setTimeout("ShowWindow", 14400000, "VBScript")

intMinutes = 245

intSeconds = 0

MaxRetry = MaxRetry - 1

End Sub

'''''''''''''''''''

'

' Call HTA window after the timer value of the hideWindow has expipred

'

'''''''''''''''''''

Sub ShowWindow

window.moveTo posLeft, posTop

window.moveTo intLeft,intTop

window.clearTimeout(idTimer)

End Sub

'''''''''''''''''''

'

' Change Idtimer value to sleep  the popup notificaton value

'

'''''''''''''''''''

Sub Sleep

 

intLeft = window.screenLeft

intTop = window.screenTop

window.moveTo -2000,-2000

idTimer = window.setTimeout("StartInstall", 600000, "VBScript")

End Sub

Sub Kill

Set objShell = CreateObject("Wscript.Shell")

Dim killprocess

processlist = Split (",winword.exe,Notepad.exe,iron.exe,iexplore.exe,outlook.exe",",")

For Each x In processlist

        objShell.Run killProcess & " /IM " & x, 0

        killprocess = "c:\windows\system32\taskkill.exe /F "

Next

idTimer = window.setTimeout("StartInstall", 8000, "VBScript")

End Sub

'''''''''''''''''''

'

' Check if some processes define in the isprocessrunning function equal true

' Start the installation if none of the processes in the function is running

' Ask user to close the processes in the process list  

'

'''''''''''''''''''  

Sub StartInstall

Const Timeout = 10

Const wshYes = 6

Const wshNo = 7

Const wshYesNoDialog = 4

Const wshQuestionMark = 32

Dim strCommand

Dim myArray

Dim isProcessRunning

Dim objWMIService, strWMIQuery, strComputer

Set objShell = CreateObject("Wscript.Shell")

'Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set intMinutes = Nothing

Set inSeconds = Nothing

msiname = "AcroRead.msi" ' You can use these variable to push msi

mstname = "AcroRead.mst" '

logname = "install.log"  '

intMinutes = -1

inSeconds = -1

intLeft = window.screenLeft

intTop = window.screenTop

window.moveTo -2000,-2000

strComputer = "."

'processlist = Array ("winword.exe","Notepad.exe","iron.exe","iexplore.exe","Outlook.exe")

'processnames = Filter(processlist,".exe",True,1)

processNames = Split (",winword.exe,Notepad.exe,iron.exe,iexplore.exe,outlook.exe",",")

Set objWMIService = GETOBJECT("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")

for each x in processNames

    strWMIQuery = "Select * from Win32_Process where name like '" & x & "'"

        

        

        

        If objWMIService.ExecQuery(strWMIQuery).Count > 0 Then

                isProcessRunning = True

        End If

Next

If isProcessRunning = True Then

        intReturn = objShell.Popup("Before installing application X you must close applications X. Do you want to close it now?",_

        , "Question", wshYesNoDialog + wshQuestionMark)

        If intReturn = wshYes Then

                kill()

                Exit Sub

        End If

    If  intReturn = wshNo Then

            Sleep()

            Exit Sub

         End If

End If

strCommand = ("C:\windows\System32\calc.exe") 'strCommand = "Msiexec /qn /i " & msiname & " TRANSFORMS=" &_

                                                                                       'mstname & " " & "ALLUSERS=TRUE" & " " & "DISABLE_CACHE=1" & " " & "REBOOT=ReallySuppress'" & " /l*v " & logname  

objShell.Run strCommand                                

window.close

Set wshshell = Nothing                

End Sub

</SCRIPT>

</head>

        

<body  onload="CloseWindow()"  bgcolor="#F0F0F0">

<a><img src="Install.ico" align="left"></a>

<strong><p align="left">Application X will be installed on your PC. If you want to start the installation now, click on install. Otherwise installation will automatically start in</strong>

<strong><div align="right" id="Text"></div><br>

<strong><div align="left" id="Text2"></div><br>

<div align="right"><select id="opt_script" name="opt_script" size="1">

<option value="opt_1">30minutes</option>

<option value="opt_2">1 hours</option>

<option value="opt_3">4 hours</option>

</select></strong>

<button name="btn_run" id="btn_run" accessKey="R" onclick="vbs:Run_Script"><u>P</u>ostpone</button>

<input type="button" value="Install" name="run_button" onClick="vbs:StartInstall()"></div>

</body>

</html>