A small tool that is written with Hta[javascript] for a timed reboot or shutdown _hta

Source: Internet
Author: User
Tags set time
Description: A gadget for scheduled restart or shutdown of a computer for Windows 2k/xp/2003
Author: 11 Wolves
Email:112183883@163.com
qq:112183883
-------------------------------------------------------------*/
Copy Code code as follows:

<!--

/*--------------------Windows Timer---------------------------------------------

Description: A gadget for scheduled restart or shutdown of a computer for Windows 2k/xp/2003
Author: 11 Wolves
Email:112183883@163.com
qq:112183883
website:http://www.w3cg.net/

-------------------------------------------------------------------------------*/

-->


<title>♀windows System Timer ♀</title>
<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >

Id= "Wtimer"
maximizebutton= "No"
minimizebutton= "Yes"
Singleinstance= "Yes"
contextmenu= "Yes"
sysmenu= "Yes"
Version= "1.0"
Innerborder= "No"
caption= "Yes"
Showintaskbar= "Yes"
Border= "Normal"
Borderstyle= "Normal"
Applicationname= "Windows Timer"
icon= "Timerico.ico"
/>

<style type= "Text/css" >
<!--
* {Font-family:courier new,arial,sans-serif;font-size:9pt;}
body {Overflow-y:hidden;}
Div a:link,div a:visited {text-decoration:none;color: #000}
Div a:hover {text-decoration:underline;color: #f00}
#footerinfo {width:100%;d isplay:table;margin-top:5px}
#left {float:left;width:70%;}
#right {float:right;width:29%;text-align:right;margin-right:1px;}
-->
</Style>

<script language= "JavaScript" >
<!--

$BL _sleep=false;

function GetObject ($obj) {
Return (document.getElementById ($obj));
}

String.prototype.parseint=function () {
Return (parseint (this));
}

function Getradioval ($name) {
$oEms =document.getelementsbyname ($name);
for ($i =0; $i < $oEms. length; $i + +) {
if ($oEms [$i].checked) {return ($oEms [$i].value);}
}
}

function isdeclared ($varName) {
Return (typeof ($varName)!= "undefined");
}

function Chstatus ($name, $status) {
$ooEms =document.getelementsbyname ($name);
for ($a =0; $a < $ooEms. length; $a + +) {
$ooEms [$a].disabled= $status;
}
}

function Window.onload () {
$sWidth =window.screen.width;
$sHeight =window.screen.height;
$aWidth = 400;
$aHeight = 185;
Window.resizeto ($aWidth, $aHeight);
Window.moveto (($sWidth-$aWidth)/2, ($sHeight-$aHeight)/2);
Document.bgcolor= "#d4d0c8";
GetObject ("Stopbutton"). Disabled=true;
GetObject ("left"). Innerhtml= "Hint: Please select the features you want to use!" ";
}

function Timer_quit () {
Window.close ();
}

function Timer_kernel () {
if ($bl _sleep) {
if (isdeclared ($time) && isdeclared ($mod _time) && isdeclared ($operation)) {
if ($time >0) {
$Oper _str= "";
$Hint _str= "";
$Titl _str= "";
if ($operation = = "Rwin") {
$Oper _str= "<span style=\" color:red\ > Tip: System timer Restart feature is enabled, please note save! </span> ";
}
else {
$Oper _str= "<span style=\" color:red\ > Tip: The system timer shutdown feature is enabled, please note save! </span> ";
}
if ($mod _time== "Mod_minute") {
$tMinute = ($time/60). toString (). parseint ();
$tSecond = $time% 60;
if ($tMinute!=0) {
if ($tSecond <10) {
$tSecond = "0" + $tSecond;
}
$Titl _str= "remaining time:" + $tMinute + "min" + $tSecond + "seconds";
}
else {
$Titl _str= "remaining time:" + $tSecond + "seconds";
}
}
else {
$Titl _str= "remaining time:" + $time + "seconds";
}
GetObject ("left"). innerhtml= $Oper _str;
document.title= $Titl _str;
$time = $time-1;
$o =settimeout ("Timer_kernel ()", 1000);
}
else {
$Flag = "";
if ($operation = = "Rwin") {
$Flag = 6; 6 Restart operating system
}
else {
$Flag = 1; 1 for shutting down the operating system
}
OperateWin32 ($Flag);
GetObject ("left"). Innerhtml= "<span style=\ color:red\" > Hint: performing a scheduled operation! </span> ";
Document.title= "Performing scheduled operations";
}
}
}
}

function Timer_stop () {
$BL _sleep=false;
if (isdeclared ($o)) {cleartimeout ($o);}
GetObject ("Time"). Disabled=false;
GetObject ("Mod_time"). Disabled=false;
Chstatus ("Operation", false);
GetObject ("Startbutton"). Disabled=false;
GetObject ("Stopbutton"). Disabled=true;
GetObject ("left"). Innerhtml= "Hint: Please select the features you want to use!" ";
document.title= "♀windows system timer ♀";
}

function Timer_start () {
$BL _sleep=true;
$nowTime = "";
$time =getobject ("Time"). Value;
$mod _time=getobject ("Mod_time"). Value;
$operation =getradioval ("operation");
if (isNaN ($time) | | | $time = = "") {
Alert ("Please set a time value correctly!") ");
GetObject ("Time"). Select ();
Return
}
else {
$time = $time. parseint ();
if ($mod _time== "Mod_minute") {$time = $time *60;}
}
GetObject ("Time"). Disabled=true;
GetObject ("Mod_time"). Disabled=true;
Chstatus ("Operation", true);
GetObject ("Startbutton"). Disabled=true;
GetObject ("Stopbutton"). Disabled=false;
Timer_kernel ();
}

function OperateWin32 ($DownFlag) {
$OS _pro=getobject ("winmgmts:{(shutdown)}//./root/cimv2"). ExecQuery ("select * from Win32_OperatingSystem where primary=true");
For ($e =new Enumerator ($OS _pro);! $e. AtEnd (); $e. MoveNext ()) {
$getProcess = $e. Item ()
$getProcess. Win32Shutdown ($DownFlag);
}
}

function responsekeypress () {
if (event.keycode==13) {event.keycode=9;}
}

-->
</Script>

<body>
<fieldset>
<table width= "100%" border= "1" cellpadding= "4" cellspacing= "3" >
<form name= "Form1" >
<tr>
&LT;TD width= "25%" > Set time:</td>
&LT;TD width= "75%" ><input type= "text" name= "Time" size= "value=" "onkeypress=" responsekeypress () "/>"
<select name= "Mod_time" >
<option value= "Mod_minute" > Min </option>
<option value= "Mod_second" > Sec </option>
</select>
</td>
</tr>
<tr>
<td> function Selection:</td>
<td>
<input type= "Radio" name= "Operation" value= "Rwin" checked= "checked"/> Restart
<input type= "Radio" name= "Operation" value= "Cwin"/> Shutdown
</td>
</tr>
<tr>
&LT;TD colspan= "2" style= "Text-align:right" >
<input type= "button" Name= "Startbutton" value= "onclick=" Timer_start () "/>"
<input type= "button" Name= "Stopbutton" value= "Cancel" onclick= "Timer_stop ()"/>
<input type= "button" Name= "Exitbutton" value= "Exit" onclick= "Timer_quit ()"/>
</td>
</tr>
</form>
</table>
</fieldset>
<div id= "Footerinfo" >
<div id= "left" ></div>
<div id= "Right" >
Author: <a href= "http://www.w3cg.net/" title= "visit author blog" > 11 wolves </a>
</div>
</div>
</body>


Recently nothing, think of the previous plan to do a timed reboot or shutdown tool, then spent a little time in the form of HTA wrote a, called "Windows Timer", screenshot as follows:

If you need a friend, you can click this link to download: Local download

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.