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-08 15:24
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Anti-addiction system in a pure batch file under the CMD environment View 2,120 Replies 19
Original Poster Posted 2008-04-07 11:27 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,284
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
Explanation:
Now games are mostly played under an XP environment, so this is called the CMD environment;
Pure batch means trying not to require third-party software support, but if there is really no way, then I’ll have to use it too;
An anti-addiction system means controlling computer usage across multiple time periods, whether programs, games, websites, etc.

Reason:
Computers are very common now, and many teenagers (the school-going kind) always play games day and night, affecting their studies. It not only affects studies, but also affects health. I’m not cut out for programming myself, so...

Reference: Computer News 2006 bound volume, page 242: “Anti-addiction tricks for computers - cleverly using ‘Scheduled Tasks’ to manage boot time”, but I still think it’s not ideal: 1. too many batch files; 2. scheduled tasks are easy to discover; 3. some functions are still lacking.

Help requirements:
1. Generate a single batch file (it can run in multi-parameter form), and make it run hidden or as a service.
2. Monitor malicious changes to the system time (it may require using a log file for time comparison)
3. When not connected to the network, handle things according to system time; when connected, support synchronizing with the time of some server on the network:
The system must have the Windows Time (W32Time) service, set to automatic
net time /setsntp:time.jmu.edu.cn ;set the time server address
net stop w32time ;stop the time service
net start w32time ;start the time service
w32tm -s ;synchronize time immediately
4. Support multiple time periods, for example: allow computer use from 9:30-11:30, 15:00-17:00, 19:00-21:00, and automatically shut down at all other times;
5. Support setting certain programs (including games), websites, etc. as forbidden to run

Because there are too many functions, if anyone feels they can’t handle all of them, replying with just a single function is also fine. Many thanks!
Floor 2 Posted 2008-04-07 15:32 ·  中国 河南 郑州 联通
初级用户
Credits 35
Posts 17
Joined 2008-04-03 01:33
18-year member
UID 114814
Gender Male
Status Offline
Pure command-line batch processing probably can’t achieve all the functions you mentioned, unless outside tools are brought in.
With so many requirements, you’d better find a software company to do it for you. The forum is for answering questions and clearing up doubts, not for helping people do projects.
....................BTW: if someone’s stuff gets taken by you and sold, that would really be something to watch.
Floor 3 Posted 2008-04-07 15:34 ·  中国 河南 郑州 联通
初级用户
Credits 35
Posts 17
Joined 2008-04-03 01:33
18-year member
UID 114814
Gender Male
Status Offline
Try to start from education; that’s best for the child.
What you’re doing should count as violent interference.
Education should still be education, hehe.
Floor 4 Posted 2008-04-07 16:15 ·  中国 广西 钦州 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Seriously, OP, I really want to take a handgun and wipe out those American aircraft carriers.
Floor 5 Posted 2008-04-07 19:11 ·  中国 广东 肇庆 电信
中级用户
★★
Credits 384
Posts 189
Joined 2005-10-19 13:12
20-year member
UID 43709
Gender Male
Status Offline
I wrote this before. But because the hard drive died, it was lost too. Right now I don’t have the time or the energy to write it again, so I hope brothers on the forum can improve it a bit.

I wrote most of the functions the OP mentioned. You can search the posts I made before; putting them together should be close enough.

As for passwords, you can use MD5.exe to encrypt, then use the setx.vbs written in VBS that brother est posted to write it into system or user variables. You can also use system time to generate a password that changes according to the time.

As for time (CMD is ineffective on numbers like 8 and 9), you can refer to the small Scheduled Tasks program posted by jastyg
http://www.cn-dos.net/forum/viewthread.php?tid=21110

For time synchronization, you can refer to this
http://www.cn-dos.net/forum/viewthread.php?tid=17659

setx.vbs
http://www.cn-dos.net/forum/viewthread.php?tid=27952
Floor 6 Posted 2008-04-07 21:50 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,284
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
The reply in post #5 looks more decent. I’ll use it for reference. Looks like there’s no real help to be had, so I can only try making it myself!
Floor 7 Posted 2008-04-08 00:46 ·  中国 福建 三明 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
OP’s requirements are very easy to achieve!
1. You can hide it with VBS
2. Use Group Policy to prohibit changing the time
3. With #2, there’s no need to sync the time online
4. shutdown -f -s -t 0 is enough to shut down. Here’s a reference:
if "%a%%b%" gtr "930" if "%a%%b%" lss "1000" (
for /f "delims=" %%i in ('"cscript //nologo E:\自编程序区\共用2.vbs It is now shutdown time. Please decide within two minutes whether to shut down; otherwise it will automatically shut down in two minutes."') do if /i %%i==no (echo.>no.bat) else shutdown -f -s -t 0)

930 and 1000 mean 9:30--10:00. As for the VBS in that line, search for it on this forum; if it’s not called 共用2, that’s the one. Of course, this one is optional—you can change it to a forced one with no choice, so when the time comes it must shut down!
5. Programs can be blocked, but a certain website is hard to deal with!!
Floor 8 Posted 2008-04-08 03:01 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
They’re all fairly easy to achieve, feels like manual labor, so I give up~

A line of thought for you:
5. To forbid programs, use image hijacking
To forbid websites, use HOSTS
Floor 9 Posted 2008-04-08 11:15 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,284
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
Thanks to post #7. I’m not familiar with VBS, so I’ll still learn to write batch files myself, and ask again if I don’t understand. I once made a system file redirection program the same way.
Because my memory isn’t too good, although I know the purpose of many commands, when actually using them I still have to check the help or refer to other people’s examples.
Floor 10 Posted 2008-04-08 13:24 ·  中国 福建 三明 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
I’m not telling you to do VBS programming, just to use VBS to start the batch file, then it can be hidden!!
CreateObject("WScript.Shell").Run "cmd /c E:\自编程序区\Q宠.bat",0

Actually I have 1 and 4 of your requirements, but I’d rather you write them yourself, that’s also good for you. You already wrote 3, so I won’t say more, and I don’t use that anyway! As for 2, apart from being easy to handle in Group Policy, the rest aren’t very good, because as long as the user knows you have such a program, they can change the time in the BIOS!!

[ Last edited by lotus516 on 2008-4-8 at 01:34 PM ]
Floor 11 Posted 2008-04-08 13:29 ·  中国 福建 三明 电信
高级用户
★★
论坛上抢劫的
Credits 551
Posts 246
Joined 2006-09-21 12:35
19-year member
UID 63270
Status Offline
For VBS see this posthttp://www.cn-dos.net/forum/viewthread.php?tid=26132&fpage=1&highlight=%E8%BF%94%E5%9B%9E
For forced choice, remove the NO from this line!
intAnswer = MsgBox("Without this setting it can only be done in Safe Mode. Continue? ", vbExclamation + vbYesNo, "Little Dot Prompt!")
Floor 12 Posted 2008-04-08 22:35 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,284
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
No choice, I can only do it step by step. First I’ll handle time logging and time encryption:
The following batch file generates a text file named datetime.log (see the quoted part). This string is arranged like this:
run time, random password, first period start, first period end, second period start, second period end, third period start, third period end
Each of the time periods above is written into the datetime.log file after adding the random password.

@echo off
set hour=%time:~0,2%
set minute=%time:~3,2%
set second=%time:~6,2%
set t6=%hour%%minute%%second%

set /a p5=%random:~0,1%%random:~0,1%%random:~0,1%%random:~0,1%%random:~0,1%
set /a t6p5=%t6%+%p5%
>datetime.log set /p=%t6p5%<nul
>>datetime.log set /p=%p5%<nul

set _one=100000
set one_=113000
set _two=140000
set two_=170000
set _three=200000
set three_=220000

set /a p5_one=%_one%+%p5%
set /a p5one_=%one_%+%p5%
set /a p5_two=%_two%+%p5%
set /a p5two_=%two_%+%p5%
set /a p5_three=%_three%+%p5%
set /a p5three_=%three_%+%p5%
>>datetime.log set /p=%p5_one%<nul
>>datetime.log set /p=%p5one_%<nul
>>datetime.log set /p=%p5_two%<nul
>>datetime.log set /p=%p5two_%<nul
>>datetime.log set /p=%p5_three%<nul
>>datetime.log set /p=%p5three_%<nul

for /f %%a in (datetime.log) do set string=%%a
echo Encrypted text: %string%
set /a password=%string:~6,5%
echo Password text: %password%
set /a runtime=%string:~0,6%-%string:~6,5%
echo Execution time: %runtime:~0,2%:%runtime:~2,2%:%runtime:~4,2%
set /a one1=%string:~11,6%-%string:~6,5%
set /a one2=%string:~17,6%-%string:~6,5%
echo First stage: %one1:~0,2%:%one1:~2,2%:%one1:~4,2%-%one2:~0,2%:%one2:~2,2%:%one2:~4,2%
set /a two1=%string:~23,6%-%string:~6,5%
set /a two2=%string:~29,6%-%string:~6,5%
echo Second stage: %two1:~0,2%:%two1:~2,2%:%two1:~4,2%-%two2:~0,2%:%two2:~2,2%:%two2:~4,2%
set /a three1=%string:~35,6%-%string:~6,5%
set /a three2=%string:~41,6%-%string:~6,5%
echo Third stage: %three1:~0,2%:%three1:~2,2%:%three1:~4,2%-%three2:~0,2%:%three2:~2,2%:%three2:~4,2%

:: ping -n 60 127.1>nul
pause


Below is the execution result of the batch file. The execution result on every machine will be absolutely different from the data below.
Encrypted text: 22154011121111121124121151121181121211121231121
Password text: 11121
Execution time: 21:04:19
First stage: 10:00:00-11:30:00
Second stage: 14:00:00-17:00:00
Third stage: 20:00:00-22:00:00
Press any key to continue. . .


Now here comes the problem:
Because the recorded time periods are all 6 digits, if I need to handle times before 10 o’clock, how should I properly handle the addition and subtraction, since this 6-digit number has a leading 0? Besides, these times still need to be written into the datetime.log file in 6-digit form.

How should this be improved?

[ Last edited by chishingchan on 2008-4-8 at 10:42 PM ]
Floor 13 Posted 2008-04-08 22:48 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,284
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
I’ve thought about this problem: add 1000000 to the time. No matter if the time is 00:00:00, that 00:00:00 would then need special handling as =1000000, or add 1 second to every time, and for times before 10 o’clock add another 1000000, then subtract back out the 1000000 when processing. I don’t know whether that would be good or not?
Floor 14 Posted 2008-04-08 22:54 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,284
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
I do have a way to handle hiding. As for using service mode, there is something on this forum, but I haven’t studied it. But that part can be dealt with later.
The core is setting, checking, handling, and other time-related issues.
Floor 15 Posted 2008-04-09 14:00 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,284
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
It would be good if everyone could give some opinions too, help out a bit!
Forum Jump: