remove button and use dropdown box in hta-vbscript -


i new hta & vbscript. have **hta** script downloaded internet delay reboot of computer.

there button delay such 30 min, 45 min, 60 min etc. use combobox(dropdown box) instead of button.

i want vbscript work dropdown box.

below code of hta.

<html>    <head>     <title>reboot notification</title>     <hta:application id="omyapp"         applicationname="reboot notification"         border="dialog"         borderstyle="normal"         caption="yes"         scroll="no"         maximizebutton="no"         minimizebutton="no"         showintaskbar="no"         singleinstance="yes"         sysmenu="no"/>     </head>      <script language = "vbscript">         dim intminutes         dim intseconds         dim strhtaproc         set objshell = createobject("wscript.shell")          sub window_onload             resizeto 600,450             moveto 600,400             intminutes = 15             intseconds = 0             getprocessid             'run reboottimer sub procedure every 1 second             itimerid = window.setinterval("reboottimer", 1000)         end sub          '*** hta application process id         sub getprocessid             strcomputer = "."             set objwmiservice = getobject("winmgmts:\\" & strcomputer & "\root\cimv2")             set colprocesses = objwmiservice.execquery("select name, handle win32_process name = 'mshta.exe'")             each objprocess in colprocesses                 strhtaproc = objprocess.handle             next         end sub          '***** update time selected value *********         sub delay30             btndisabled             intminutes = 30             intseconds = 0         end sub          sub delay45             btndisabled             intminutes = 45             intseconds = 0         end sub          sub delay60             btndisabled             intminutes = 60             intseconds = 0         end sub            sub delay90             btndisabled             intminutes = 90             intseconds = 0         end sub            sub delay120             btndisabled             intminutes = 120             intseconds = 0         end sub            sub delay240             btndisabled             intminutes = 240             intseconds = 0         end sub  function document_onkeydown()      dim alt     alt = window.event.altkey     select case window.event.keycode         case 27,116             window.event.keycode = 0             window.event.cancelbubble = true             document_onkeydown = false         case 115             if alt                 window.event.keycode = 0                 window.event.cancelbubble = true                 document_onkeydown = false             end if         case else             document_onkeydown = true     end select  end function           '*************************************************          '*** disable of buttons once 1 selected         sub btndisabled             btndelay30.disabled = true             btndelay45.disabled = true             btndelay60.disabled = true             btndelay90.disabled = true             btndelay120.disabled = true             btndelay240.disabled = true         end sub          sub reboottimer             if intseconds = 0                 if intminutes = 0 , intseconds = 0 'reboot workstations                     objshell.appactivate strhtaproc                     objshell.run "shutdown -r -f -t 0"                 else                     intminutes = intminutes - 1                 end if                 intseconds = 59             else                  intseconds = intseconds - 1             end if              'update clock              clock.innerhtml = "a reboot occur in " & "<strong>" & intminutes & ":" & right("00" & intseconds, 2) & "</strong>"              'activate hta application @ 1, 5, , 10 minutes remind user             if intminutes = 1 , intseconds = 0                 objshell.appactivate strhtaproc             elseif intminutes = 5 , intseconds = 0                 objshell.appactivate strhtaproc             elseif intminutes = 10 , intseconds = 0                 objshell.appactivate strhtaproc             end if          end sub      </script>      <body onload="window.focus()" style="filter:progid:dximagetransform.microsoft.gradient(gradienttype=0, startcolorstr='#9bc59f', endcolorstr='#508855')">         <h2 p style="text-align: center; "><span>reboot notification</h2></span></p>         <h3 p style="text-align: center; "><span>your workstation requires reboot</h3></span></p>         <p style="text-align: center;"><span id="clock"></span></p>               <p style="text-align: center;"><input id=btndelay30 class="button" type="button" value="delay 30 minutes" name="btndelay30" onclick="delay30"/></p>         <p style="text-align: center;"><input id=btndelay45 class="button" type="button" value="delay 45 minutes" name="btndelay45" onclick="delay45"/></p>         <p style="text-align: center;"><input id=btndelay60 class="button" type="button" value="delay 60 minutes" name="btndelay60" onclick="delay60"/></p>         <p style="text-align: center;"><input id=btndelay90 class="button" type="button" value="delay 90 minutes" name="btndelay90" onclick="delay90"/></p>         <p style="text-align: center;"><input id=btndelay120 class="button" type="button" value="delay 120 minutes" name="btndelay120" onclick="delay120"/></p>         <p style="text-align: center;"><input id=btndelay240 class="button" type="button" value="delay 240 minutes" name="btndelay240" onclick="delay240"/></p>         <p style="text-align: center; font-size:14px;"><span>if have questions please contact helpdesk @ ext. ####</span></p>     </body>  </html> 

edit

i can show dropdown box on hta application don't know how manage vbscript that.

basically should value select element. let's select element has name btndelay. value of btndelay should use btndelay.value

enjoy

<html>    <head>     <title>reboot notification</title>     <hta:application id="omyapp"         applicationname="reboot notification"         border="dialog"         borderstyle="normal"         caption="yes"         scroll="no"         maximizebutton="no"         minimizebutton="no"         showintaskbar="no"         singleinstance="yes"         sysmenu="no"/>     </head>      <script language = "vbscript">         dim intminutes         dim intseconds         dim strhtaproc         set objshell = createobject("wscript.shell")          sub window_onload             resizeto 600,550             moveto 300,300             intminutes = 15             intseconds = 0             getprocessid             'run reboottimer sub procedure every 1 second             itimerid = window.setinterval("reboottimer", 1000)         end sub          '*** hta application process id         sub getprocessid             strcomputer = "."             set objwmiservice = getobject("winmgmts:\\" & strcomputer & "\root\cimv2")             set colprocesses = objwmiservice.execquery("select name, handle win32_process name = 'mshta.exe'")             each objprocess in colprocesses                 strhtaproc = objprocess.handle             next         end sub          '***** update time selected value *********     sub setdelay             btndisabled             intminutes = btndelay.value             intseconds = 0     end sub  function document_onkeydown()      dim alt     alt = window.event.altkey     select case window.event.keycode         case 27,116             window.event.keycode = 0             window.event.cancelbubble = true             document_onkeydown = false         case 115             if alt                 window.event.keycode = 0                 window.event.cancelbubble = true                 document_onkeydown = false             end if         case else             document_onkeydown = true     end select  end function           '*************************************************          '*** disable of buttons once 1 selected         sub btndisabled             btndelay.disabled = true         end sub          sub reboottimer             if intseconds = 0                 if intminutes = 0 , intseconds = 0 'reboot workstations                     objshell.appactivate strhtaproc                     objshell.run "shutdown -r -f -t 0"                 else                     intminutes = intminutes - 1                 end if                 intseconds = 59             else                  intseconds = intseconds - 1             end if              'update clock              clock.innerhtml = "a reboot occur in " & "<strong>" & intminutes & ":" & right("00" & intseconds, 2) & "</strong>"              'activate hta application @ 1, 5, , 10 minutes remind user             if intminutes = 1 , intseconds = 0                 objshell.appactivate strhtaproc             elseif intminutes = 5 , intseconds = 0                 objshell.appactivate strhtaproc             elseif intminutes = 10 , intseconds = 0                 objshell.appactivate strhtaproc             end if          end sub      </script>      <body onload="window.focus()" style="filter:progid:dximagetransform.microsoft.gradient(gradienttype=0, startcolorstr='#9bc59f', endcolorstr='#508855')">         <h2 p style="text-align: center; "><span>reboot notification</h2></span></p>         <h3 p style="text-align: center; "><span>your workstation requires reboot</h3></span></p>         <p style="text-align: center;"><span id="clock"></span></p>           <select size="1" name="btndelay" onchange="setdelay">         <option value="30">delay 30 minutes         <option value="45">delay 45 minutes         <option value="60">delay 60 minutes         <option value="90">delay 60 minutes         <option value="120">delay 120 minutes         <option value="240">delay 240 minutes     </select>         <p style="text-align: center; font-size:14px;"><span>if have questions please contact helpdesk @ ext. ####</span></p>     </body>  </html> 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -