China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-03 11:50
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Pop up a prompt after the specified time View 2,581 Replies 18
Original Poster Posted 2006-12-25 11:32 ·  中国 江西 吉安 遂川县 电信
中级用户
★★
Credits 253
Posts 112
Joined 2006-05-31 11:12
20-year member
UID 56308
Gender Male
Status Offline
I want to write something to achieve the following effects
After running /
Requires entering a time (a, unit: hours),
After entering, a pop-up window "The online time you set is a hours!" pops up
This pop-up window hides by itself after 3 seconds!
A prompt pops up every 15 minutes: Protect your eyes! The prompt box disappears after 15 seconds~
Then when the time (a) you just entered is about to reach (for example, if you enter 1, it is at 59 minutes), prompt "The time you limited has arrived! Please be ready to log off!" (Preferably, a countdown can be displayed at the same time! 60-59-58...1-0)
When the countdown is 0 (that is, the entered time a arrives), run a certain program!

It should be achievable with vbs? But I don't understand, and I only have a slight understanding of bat~ If it can be written with bat, it would be better^_^~~
I also posted a request in this forum, but the answers received are not many~ Alas.

Preferably, no third-party software is used~~ I have searched online many times, and there are few that can really satisfy. I want to implement something that everyone can use!
The purpose of making this thing is obvious, which is to remind some people who use the computer frequently! Pay attention to their own health!
I myself have caused high myopia now because I didn't pay attention to eye-related issues and faced the monitor for a long time!
It's too late to regret! I can only hope that a certain expert can write such a thing.
Put this thing in the Internet cafe, so that (or urge) each online user can develop a good eye care habit!
Wish every computer enthusiast, while enjoying the joy brought by the computer, can always have a pair of bright eyes!

Merry Christmas~~~~~~

Hoping!
Floor 2 Posted 2006-12-25 13:51 ·  中国 江西 赣州 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
I made a batch, the code is a bit messy!! But it's okay!!! I don't have much time and didn't test it for an hour!!! You test it yourself!!!!
First sofa!! Hehe!!!
@echo off
set /p a=The time you set for using the computer is a hours:
set /a b=%a%
set /a d=%a%*4
set /a d=%d%-1
msg %username% /time:3 "The time you set for using the computer is %a% hours!"
set /a c=1
set /a e=15
setlocal enabledelayedexpansion
:1
sleep 900000
msg %username% /time:15 ":)........Protect your eyes........:)"
if !e! equ 14 goto 3
if !c! equ !d! set /a e=14
set /a c+=1&&goto 1
:3
sleep 840000
set f=60
:4
msg %username% /time:1 ":)There are still !f! seconds until the time is up! Please make a backup!!!:)"
set /a f-=1
if !f! GEQ 1 goto 4
sleep 60000
exit

The sleep software has accurate time (millisecond level)!! The memory usage is not much!!! (388k)
A small drawback must be an integer hour!!!
The sleep must be in the same folder as the batch, otherwise the sleep in the code should be changed to the specific path!! Such as d:\sleep.exe
Corrected a few serious errors!!
If the owner needs it, change exit to the program you want to run!!!

[ Last edited by lotus516 on 2006-12-25 at 03:47 PM ]
Floor 3 Posted 2006-12-25 22:15 ·  中国 福建 福州 电信
初级用户
Credits 58
Posts 22
Joined 2005-12-15 13:29
20-year member
UID 47187
Status Offline
Learning

Still need external commands

But it's difficult to make BAT use internal commands to achieve the effect!
Floor 4 Posted 2006-12-25 22:39 ·  中国 辽宁 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
I think maybe I can call the shutdown command.
Floor 5 Posted 2006-12-25 23:27 ·  中国 上海 嘉定区 电信
初级用户
Credits 100
Posts 46
Joined 2006-12-19 04:57
19-year member
UID 73922
Gender Male
Status Offline
But shutdown seems to require administrator privileges. Otherwise, it can't be executed.
Floor 6 Posted 2006-12-25 23:47 ·  中国 广东 肇庆 四会市 电信
中级用户
★★
Credits 384
Posts 189
Joined 2005-10-19 13:12
20-year member
UID 43709
Gender Male
Status Offline
It might be a bit difficult if you're not an administrator...

Also, what is the operating environment of the original poster??????........
Floor 7 Posted 2006-12-25 23:54 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Can timing be done in a special way?

Flexibly use ping -w [ms] -n 1 non - existent IP
For example, ping -n 1 -w 1000 1.255
Floor 8 Posted 2006-12-26 00:21 ·  中国 山西 太原 联通
初级用户
Credits 51
Posts 20
Joined 2006-12-07 01:09
19-year member
UID 72766
Gender Male
Status Offline
Floor 9 Posted 2006-12-26 07:17 ·  中国 江西 赣州 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
Originally posted by everest79 at 2006-12-25 23:54:
Can timing be done in a special way?

Flexibly use ping -w -n 1 non-existent IP
For example, ping -n 1 -w 1000 1.255

It's not that it can't be done, but the precision is not high. The owner has high requirements, and ping won't work!!
Are there any more ingenious techniques for batch processing delays?http://www.cn-dos.net/forum/viewthread.php?tid=23475&fpage=1&highlight=%E6%89%B9%E5%A4%84%E7%90%86%E5%BB%B6%E6%97%B6%E8%BF%98%E6%9C%89%E4%BB%80%E4%B9%88%E7%B2%BE%E5%B7%A7%E7%82%B9%E7%9A%84%E6%8A%80%E5%B7%A7%E5%90%97%EF%BC%9F
Floor 10 Posted 2006-12-26 08:13 ·  中国 江西 吉安 遂川县 电信
中级用户
★★
Credits 253
Posts 112
Joined 2006-05-31 11:12
20-year member
UID 56308
Gender Male
Status Offline
Operation failed!

Prompt: Error 1702 when getting the session name

This is the problem I encountered when running...
windows xp sp2

Also, can you write a vbs to achieve the above function.
Brother lotus516's code didn't test successfully. I don't know if there will be a command prompt window in the taskbar after running??
I think the best code written should not have any things appear in the taskbar after running~~vbs should be able to achieve that, right?
Floor 11 Posted 2006-12-26 09:28 ·  中国 江西 赣州 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
Originally posted by junyee at 2006-12-26 08:13:
Run failed!

Prompt: Error 1702 when getting session name

This is the problem I encountered when running...
Windows XP SP2

Also, can a VBS be written to achieve the above function.
Brother lotus516's ...

I can do it without SP2! There are windows in the taskbar, but VBS can't make windows. But I just can't figure out how to make the window! Also, it can be made into a service to eliminate the window!

[ Last edited by lotus516 on 2006-12-26 at 09:35 AM ]
Floor 12 Posted 2006-12-26 10:34 ·  中国 江西 吉安 遂川县 电信
中级用户
★★
Credits 253
Posts 112
Joined 2006-05-31 11:12
20-year member
UID 56308
Gender Male
Status Offline
, thank you in advance...
There are many VBS experts in the forum~~~Come and help!
Floor 13 Posted 2006-12-26 12:03 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
Roughly written one, not tested. For reference only. (The time cannot be as accurate as you said, some functions cannot be realized)


set ws=createobject("wscript.shell")
set fso=createobject("scripting.filesystemobject")
a=inputbox("Please set your computer time. (Unit: hours)","Prompt")
ws.popup "The time you set is " & a& " hours",3,"Prompt"
starttime=timer
do
endtime=timer
sysj=endtime-starttime
if sysj>=3600*a-60 then
ws.popup"Your limited time is up! Please be ready to log off!",60,"Prompt"
ws.run "cmd" 'This is the program you want to run
wscript.quit
end if
if sysj <3600*a-960 then
wscript.sleep 1000*15*60
ws.Popup"Protect your eyes!", 15, "System Prompt"
else
wscript.sleep 1000
end if
loop


[ Last edited by jmz573515 on 2006-12-26 at 09:49 AM ]
Floor 14 Posted 2007-02-12 14:36 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Using the at command

c:\>at /?
The AT command schedules commands and programs to run at a specific date and time.
To use the AT command, the Schedule Service must be running.
Floor 15 Posted 2007-02-12 22:13 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
The VBScript on floor 13 pops up a prompt at the 16th minute, and the test is okay. But the prompt when the final time is up is not implemented?
Forum Jump: