<TITLE>Exemple Timer CheckBoxes</TITLE> <HTA:APPLICATION ID="Exemple TmChkBx" SCROLL="no" SCROLLFLAT="no" SINGLEINSTANCE="yes" SHOWINTASKBAR="yes" SysMenu="yes" MAXIMIZEBUTTON="no" MINIMIZEBUTTON="yes" BORDER="thin" BORDERSTYLE="complex" INNERBORDER="no" CAPTION="yes" WINDOWSTATE="normal" APPLICATIONNAME="EInstlApp" ICON="%SystemRoot%\explorer.exe"> <style type="text/css"> body { backGround-color:#EFE9E3; margin:5px; } .countdown { height:20px; font:11px; font-weight:bold; font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; color:#001141; text-align:center; padding:4px 0px 0px 0px; filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr="AliceBlue",endColorStr="SeaGreen"); } .button { height:20px; cursor:Hand; font:11px; font-weight:bold; font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; color:#40404; filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr="#E5E5E5",EndColorStr="#7D7D7D"); border:0px 0px 0px 0px transparent; } td { font-size:11px; font-weight:Bold; font-family:Segoe Ui, Arial,Tahoma,Comic Sans MS; color:#000000; } </style> <script language="JScript"> //-> Resize And Place In Approx Center window.resizeTo(620,420) window.moveTo(screen.availWidth/2-(620/2),screen.availHeight/2-(420/2)) //-> Objects For Runtime var Act = new ActiveXObject("Wscript.Shell"); var Fso = new ActiveXObject("Scripting.FileSystemObject"); //-> Runtime Varible var Tm1="";Ct=60;Cnf=false;Cbx="";Fns=false //-> Body OnLoad Function window.onload=function(){ Countdown(); } //-> Stop F5 From Closing HTA document.onkeydown=function(){ if(event.keyCode==116){ event.keyCode=0; event.cancelBubble=true; return false; } } //-> Countdown function Countdown(){ if(Ct==0){ DefaultAction(); Fns=true } if(Fns==true){ window.close(); } Txt1.innerHTML="Default Action in: "+Ct+" Seconds" Ct = Ct - 1 Tm1=window.setTimeout("Countdown()",1000); } //-> Function To Cancel Countdown function cancelcountdown(){ Cnf=true window.clearTimeout(Tm1);Tm1="" Txt1.innerHTML="Default Action Canceled".fontcolor("#690000").bold(); } //-> Default Action If Nothing Changes function DefaultAction(){ window.clearInterval(Tm1);Tm1="" Txt1.innerHTML="Processing Default Settings".fontcolor("#003300").bold(); submit(); } //-> Toggles Disabled = True Or False = L function CbxOff(L){ for(var k=0;k<CBO.length;k++){ CBO[k].disabled=L; } } //-> Add Zero To A Number function AZero(N,T){ if(T>=2 && T<=3){ N="00"+N; return Right(N,T); }else{ return N; } } //-> Process Only Checked Checkboxes function submit(){ CbxOff(true) window.clearInterval(Tm1);Tm1="" Txt1.innerHTML="Processing User Choices".fontcolor("#003300").bold(); //-> THE SCRIPT PROBLEM STARTS HERE <-// for(var i=-1; i > CBO.length; i--){ if(CBO[i].value==null==false && CBO[i].checked){ P = Act.ExpandEnvironmentStrings(CBO(i).value) A = Act.ExpandEnvironmentStrings(CBO(i).switch) try{ Act.Run(c34+P+c34+c34+A+c34" 1,true); } catch(e){ /*Error Code For Selected But Could Not Run*/; } } } //-> THE SCRIPT PROBLEM ENDS HERE <-// } </script> <body onbeforeunload="window.close()"> <table width="100%"> <td>Select the application that you want to change from the default choice below. When The Counter reaches Zero and no choices have been change, it will run these default settings.</td> </table> <table width="100%" border="1"> <td align="center"> <table> <td>Application 1</td> <td><input type="checkbox" name="CBO" id="Application 1" value="%WinDir%\notepad.exe" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 2</td> <td><input type="checkbox" name="CBO" id="Calculator" value="%WinDir%\system32\calc.exe" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 3</td> <td><input type="checkbox" name="CBO" id="Application 3" value="%SystemDrive%\temp\Program1.exe" switch="/silent /norestart /LoadInf="%SystemDrive%\temp\Program1.ini"" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 4</td> <td><input type="checkbox" name="CBO" id="Application 4" value="Checkbox 4 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 5</td> <td><input type="checkbox" name="CBO" id="Application 5" value="Checkbox 5 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 6</td> <td><input type="checkbox" name="CBO" id="Application 6" value="Checkbox 6 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 7</td> <td><input type="checkbox" name="CBO" id="Application 7" value="Checkbox 7 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 8</td> <td><input type="checkbox" name="CBO" id="Application 8" value="Checkbox 8 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 9</td> <td><input type="checkbox" name="CBO" id="Application 9" value="Checkbox 9 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 10</td> <td><input type="checkbox" name="CBO" id="Application 10" value="Checkbox 10 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> </td> <td align="center"> <table> <td>Application 11</td> <td><input type="checkbox" name="CBO" id="Application 11" value="Checkbox 11 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 12</td> <td><input type="checkbox" name="CBO" id="Application 12" value="Checkbox 12 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 13</td> <td><input type="checkbox" name="CBO" id="Application 13" value="Checkbox 13 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 14</td> <td><input type="checkbox" name="CBO" id="Application 14" value="Checkbox 14 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 15</td> <td><input type="checkbox" name="CBO" id="Application 15" value="Checkbox 15 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 16</td> <td><input type="checkbox" name="CBO" id="Application 16" value="Checkbox 16 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 17</td> <td><input type="checkbox" name="CBO" id="Application 17" value="Checkbox 17 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 18</td> <td><input type="checkbox" name="CBO" id="Application 18" value="Checkbox 18 Selected" switch="" onclick="cancelcountdown()" checked></input></td> </table> <table> <td>Application 19</td> <td><input type="checkbox" name="CBO" id="Application 19" value="Checkbox 19 Selected" switch="" onclick="cancelcountdown()"></input></td> </table> <table> <td>Application 20</td> <td><input type="checkbox" name="CBO" id="Application 20" value="Checkbox 20 Selected" switch="" onclick="cancelcountdown()"></input></td> </table> </td> </table> <table> <tr> <td><div id="Txt1" class="countdown" Style="margin:10px 0px 0px 4px;width:180px;"></div></td> <td> <button type="button" id="button1" class="button" Style="margin:10px 0px 0px 2px;width:120px;" onclick="cancelcountdown()">Cancel Countdown</button> <button type="button" id="button2" class="button" Style="margin:10px 0px 0px 20px;width:100px;" onclick="submit()">Submit</button> <button type="button" id="button3" class="button" Style="margin:10px 0px 0px 20px;width:80px;" onclick="window.close()">Quit</button> </td> </tr> </table> </body>