hta實(shí)現(xiàn)的定時(shí)關(guān)機(jī)小程序

字號(hào):


    定時(shí)關(guān)機(jī)小程序
    界面:
    代碼如下:
    <head>
    <title>定時(shí)關(guān)機(jī)小程序</title>
    <hta:application
         applicationname=hta test
      borde=thin
      borderstyle=raised
      icon=c:\windows\system32\control.exe
         scroll=no
         singleinstance=yes
      maximizebutton=no
      minimizebutton=no
         windowstate=normal
    >
    </head>
    <script language=vbscript>
     sub window_onload
      strcomputer = .
      set objwmiservice = getobject(winmgmts:\\ & strcomputer & \root\cimv2)
      set colitems = objwmiservice.execquery(select * from win32_desktopmonitor)
      for each objitem in colitems
       inthorizontal = objitem.screenwidth
       intvertical = objitem.screenheight
      next
      intleft = (inthorizontal - 240) / 2
      inttop = (intvertical - 500) / 2
      window.resizeto 240,500
      window.moveto intleft, inttop
     end sub
        sub onesub
      set objectshell=createobject(wscript.shell)
      ireturn = objectshell.run(shutdown -s -f -t 1800, 0, true)
        end sub
        sub twosub
      set objectshell=createobject(wscript.shell)
      ireturn = objectshell.run(shutdown -s -f -t 2700, 0, true)
        end sub
        sub thrsub
      set objectshell=createobject(wscript.shell)
      ireturn = objectshell.run(shutdown -s -f -t 3600, 0, true)
        end sub
     sub ok
      if isnumeric(text.value) then
       overtime = text.value * 60
       set objectshell=createobject(wscript.shell)
       ireturn = objectshell.run(shutdown -s -f -t & overtime, 0, true)
      else
       msgbox 請(qǐng)輸入一個(gè)有效的數(shù)字。
      end if
        end sub
        sub shutdown
      set objectshell=createobject(wscript.shell)
      ireturn = objectshell.run(shutdown -s -t 0, 0, true)
        end sub
        sub eshutdown
      set objectshell=createobject(wscript.shell)
      ireturn = objectshell.run(shutdown -a, 0, true)
        end sub
    </script>
    <body>
    <br>
    <center><div><input type=button style=height:30px;line-height:20px;border:1px solid #aaa; value=30 分鐘后關(guān)閉計(jì)算機(jī) name=run_button onclick=onesub><p> </div></center>
    <center><div><input type=button style=height:30px;line-height:20px;border:1px solid #aaa; value=45 分鐘后關(guān)閉計(jì)算機(jī) name=run_button onclick=twosub><p> </div></center>
    <center><div><input type=button style=height:30px;line-height:20px;border:1px solid #aaa; value=60 分鐘后關(guān)閉計(jì)算機(jī) name=run_button onclick=thrsub><p> </div></center>
    <br>
     自定義時(shí)間(分鐘):<p>
     <input type=text name=text id=text style=height:23px;width:120px;line-height:20px;border:1px solid #aaa;/> 
    <input name=submit type=submit style=width:50px;height:23px;line-height:20px;border:1px solid #aaa; value=確定 onclick=ok><p>
    <br>
    <center><div><input type=button style=height:30px;line-height:20px;border:1px solid #aaa; value=取消計(jì)劃中的注銷 name=run_button  onclick=eshutdown><p> </div></center>
    <center><div><input type=button style=height:30px;line-height:20px;border:1px solid #aaa; value= 關(guān)閉計(jì)算機(jī) name=run_button  onclick=shutdown><p> </div></center>
    <br>
    <center><div><a href=http://www.enun.net/>http://www.enun.net/</a></div></center>
    </body>