中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-06 06:25
48,039 topics / 350,124 posts / today 2 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » [Original] Tool for Scheduling Reboot or Shutdown of Computer (Modified Version)
Printable Version  2,396 / 17
Floor1 112183883 Posted 2007-04-19 15:52
初级用户 Posts 31 Credits 128
HTA format file, the screenshot is as follows:



The source code is as follows, save it as a.hta suffix file to see the effect:

<!--

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

Description: A small tool for timing restart or shutdown of the computer, suitable for Windows 2K/XP/2003
Author: Shiyi Lang
Email: 112183883@163.com
QQ: 112183883
WebSite:http://www.w3cg.net/

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

-->

<html>

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

<hta:application
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%;display: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.checked) { return($oEms.value); }
}
}

function isDeclared($varName) {
return(typeof($varName)!="undefined");
}

function chStatus($name,$status) {
$ooEms=document.getElementsByName($name);
for ($a=0;$a<$ooEms.length;$a++) {
$ooEms.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="Tip: Please select the function 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: The system timing restart function has been enabled, please pay attention to saving!</span>";
}
else {
$Oper_str="<span style=\"color:red\">Tip: The system timing shutdown function has been enabled, please pay attention to saving!</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+" minutes "+$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 is to restart the operating system
}
else {
$Flag=1; // 1 is to shut down the operating system
}
OperateWin32($Flag);
getObject("left").innerHTML="<span style=\"color:red\">Tip: Executing the scheduled operation!</span>";
document.title="Executing the scheduled operation";
}
}
}
}

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="Tip: Please select the function 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 correct time value! ");
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>
</head>

<body>
<fieldset>
<table width="100%" border="1" cellpadding="4" cellspacing="3">
<form name="form1">
<tr>
<td width="25%">Set time:</td>
<td width="75%"><input type="text" name="time" size="20" value="" onkeypress="ResponseKeyPress()" />
<select name="mod_time">
<option value="mod_minute">minutes</option>
<option value="mod_second">seconds</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" />Shut down
</td>
</tr>
<tr>
<td colspan="2" style="text-align:right">
<input type="button" name="StartButton" value=" Apply " 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 the author's blog">Shiyi Lang</a>
</div>
</div>
</body>

</html>

Supplementary note: A little modification has been made. . (4.19)

If needed, please click the attachment to download.

[ Last edited by 112183883 on 2007-4-20 at 10:57 AM ]

Attachments
♀Windows系统计时器♀.rar (5.74 KiB)
Floor2 baomaboy Posted 2007-04-19 15:58
银牌会员 Posts 554 Credits 1,513
Floor3 bw070 Posted 2007-04-19 23:38
中级用户 Posts 137 Credits 292
It seems to be written in HTML and Java languages
Floor4 bw070 Posted 2007-04-19 23:56
中级用户 Posts 137 Credits 292
Hahaha, took a look, not bad not bad~ Come back to top it!!!!
So the effect of changing the htm suffix to hta is like this, learned it~~
Hehe, I know a bit of html, can program now
Thanks~ Learned it!

Annotation:

HTA Introduction: HTA is the abbreviation of HTML Application (HTML Application), a new concept in software development. Directly saving HTML as HTA format is an independent application software, which is not much different from software designed by programming languages such as VB, C++.

[ Last edited by bw070 on 2007-4-19 at 10:58 AM ]
Floor5 htysm Posted 2007-04-20 00:19
高级用户 Posts 415 Credits 866
I know nothing about HTML, but still get extra points.
Floor6 htysm Posted 2007-04-20 00:22
高级用户 Posts 415 Credits 866
But a small problem of shutting down and restarting actually uses such a long code. I think it's not worth it. It would be best to solve it with one line of code.
Floor7 zh159 Posted 2007-04-20 00:36
金牌会员 Posts 1,467 Credits 3,687
Originally posted by htysm at 2007-4-19 11:22:
But it's just a small problem of shutting down and restarting, but such a long code is used. I feel it's not worth it. It would be best to do it with one line of code.

See if you can use one line of code to handle interface settings, set time, function selection, countdown display, and cancel setting
Floor8 112183883 Posted 2007-04-20 00:46
初级用户 Posts 31 Credits 128
Hehe, thank you to the各位 upstairs. As mentioned by the upstairs, I mainly want to make an interface. When it comes to functions, indeed, not many functions have been added. Most of the functions of the above tool can be implemented with very concise VBS or BAT commands. It's just that I either don't do it or make it more beautiful. I'm a person who tends to be perfect in everything.

Some friends said that it can be done with one line of code. Indeed, but I don't know what you're talking about? rundll32.exe? shutdown? The rundll32 program can indeed be implemented, but it requires a deep understanding of the system API. I think many friends may not be familiar with that thing. As for shutdown, it's just an encapsulation of the API, and the time setting can't exceed 600 seconds, that is, ten minutes. The most crucial point is that it's not supported in 2K (don't tell me to copy from XP, hehe, thank you for your attention to this tool, and also thank you for the points).

I'm used to leaving the computer on when I sleep and listening to some music to sleep, but the depressed thing is that I often fall asleep while listening and forget to turn off the computer, so I made this small tool to help me shut down. Hehe, if this little thing can bring you even a little bit of convenience, I will be deeply honored!

[ Last edited by 112183883 on 2007-4-20 at 12:49 AM ]
Floor9 htysm Posted 2007-04-20 01:05
高级用户 Posts 415 Credits 866
shutdown -s -f -t 8888 -c "This has exceeded several hours"
Floor10 112183883 Posted 2007-04-20 10:45
初级用户 Posts 31 Credits 128
Thanks to the person above, I've learned something. I always thought that shutdown could only set 600 seconds.
Floor11 Vampire Posted 2007-04-20 11:18
初级用户 Posts 78 Credits 176
I just downloaded it, but why can't I use it?
Floor12 Vampire Posted 2007-04-20 11:20
初级用户 Posts 78 Credits 176
Please provide the content of the picture so that I can perform the translation.

Attachments
未命名.JPG (52.53 KiB)
Floor13 112183883 Posted 2007-04-20 11:57
初级用户 Posts 31 Credits 128
Remove the following from the code and then try again.

<!--

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

Description: A small tool for timing restart or shutdown of the computer, suitable for Windows 2K/XP/2003
Author: Eleven Wolf
Email:112183883@163.com
QQ:112183883
WebSite:http://www.w3cg.net/

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

-->
Floor14 guxingyibei Posted 2007-04-20 12:01
初级用户 Posts 32 Credits 68
Want to know what's the difference between hta and html? The former is graphical interface, the latter is web form, is there any other difference!?

Top
Floor15 112183883 Posted 2007-04-20 12:04
初级用户 Posts 31 Credits 128
Everything is normal here. Screenshot:



What system are you using?
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023