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-07-01 14:58
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Please provide the specific content or more details about the requirements for the batch program to delete files immediately so that I can help you translate or further process it. Currently, the information is too simple. View 12,946 Replies 36
Floor 16 Posted 2006-10-25 20:27 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
I learned a new command from the original poster, thank you, and I've learned something new again.

PS: The original poster's method is to search the hard drive. I think the efficiency may not be very high. If we change to using taskkill to end the qqgame process, will it be a little less burden on the computer? Moreover, in order to reduce the burden on the computer, we can set a longer time. Your classmate suddenly quit playing QQ Games after only a few minutes of playing, and after several times, out of the unknown reason, he didn't want to play anymore. Using DEL to delete has a very small possibility of encountering "Another program is using this file, and the process cannot access it."
Floor 17 Posted 2006-10-25 21:07 ·  中国 江苏 无锡 宜兴市 电信
初级用户
Credits 44
Posts 16
Joined 2006-08-15 07:15
19-year member
UID 60550
Status Offline
Learned. Really good.
Floor 18 Posted 2006-10-25 21:34 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
I'm very happy that my post has come up again, and I can let everyone learn more knowledge.

Thanks for the guidance from naturaljo. During these days, I've modified this batch processing to be more user-friendly. I've already added the taskkill you mentioned. Now the thought of the implemented batch processing is: after booting, run a plan, check every three minutes whether there is the qqgame.exe program in the hard disk. If not, exit; if there is, create a plan, and it will execute itself to end and delete the programs related to qqgame.exe after one hour. This batch processing for ending and deleting resides in the memory. I want them to only play for one hour. Also, I can't prevent them from playing all the time, after all, they are friends. I mainly want to use this kind of thinking to learn batch processing in application.

[ Last edited by tianzizhi on 2006-10-25 at 09:57 PM ]
Floor 19 Posted 2006-10-25 21:52 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
I put the batch processing I have applied up for everyone to see. Experts can also give some guidance, and novices can learn from it. Thank you.
This batch processing is divided into three parts:
The first part is the part that runs a plan at boot:
First, create a task on the computer: schtasks /create /ru system /sc 3 /mo minute /tn zhang /tr d:\common\g.vbs. After creating it, there is no need to worry about it later; it will always be in the computer in the future.
The content of the batch processing connected by g.vbs is:
@echo off
schtasks /change /tn zhang /ru system /enable
schtasks /run /tn zhang

This is the first part of running the plan part. The following is the second part, the part of performing the check:
The following execution parts have two writing methods
One:
@echo off
for %%1 in (c: d:) do @%%1 & dir QQGame.exe /s /a /b>>c:\windows\dir.txt
type c:\windows\dir.txt | find "QQGame.exe" /i
if errorlevel 1 goto end
if errorlevel 0 goto zhang

:end
exit
:zhang
@echo off

setlocal ENABLEDELAYEDEXPANSION

set /a next_hour=0
set /a next_minute=0

for /F "tokens=1,2 delims=:" %%i in ('TIME /t') do (
rem Here 1 is the interval time, which can be adjusted by yourself as needed
set /a next_minute=1%%j-100

set /a next_hour=1%%i-100+1

if !next_minute! GEQ 60 (
set /a next_minute=!next_minute!-60
set /a next_hour=!next_hour!+1
if !next_hour! GEQ 24 set /a next_hour=!next_hour!-24
)
)
schtasks /change /tn zhang /ru system /disable
copy d:\common\dir.txt c:\windows\ /y
at !next_hour!:!next_minute! d:\common\d.vbs

endlocal

Two: @echo off
for %%1 in (c: d:) do @%%1 & dir QQGame.exe /s /a /b>>c:\windows\dir.txt
type c:\windows\dir.txt | find "QQGame.exe" /i
if errorlevel 1 goto end
if errorlevel 0 goto zhang

:end
exit
:zhang
@echo off
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem Here 1 is the interval time, which can be adjusted by yourself as needed
set a=%time:~0,2%
echo %a%
set /a next_hour=a+1
set a=%time:~3,2%
if %a:~0,1%==0 (set /a next_minute=%a:~1%+1) else set /a next_minute=a+1
if %next_minute% GEQ 60 (set /a next_minute=!next_minute!-60
set /a next_hour=!next_hour!+1
if !next_hour! GEQ 24 set /a next_hour=!next_hour!-24
)
schtasks /change /tn zhang /ru system /disable
copy d:\common\dir.txt c:\windows\ /y
at !next_hour!:!next_minute! d:\common\d.vbs
endlocal

The above is the part of the second part check. The following is the third part, the part of executing the end task and deleting the program when the time comes:
@echo off
:zhang
for %%1 in (c: d:) do @taskkill /f /t /im qqgame.exe & del %%1\qqgame*.* /s /a
choice /t 120 /d y
goto zhang

Well, that's all. Please take a look. Also, please ask the experts to put forward better suggestions to improve it. Thank you!!!
Floor 20 Posted 2006-10-25 22:34 ·  中国 广东 深圳 福田区 电信
初级用户
★★
Credits 133
Posts 57
Joined 2006-03-15 23:12
20-year member
UID 52128
Status Offline
The spirit of the thread starter is worth me learning!
Floor 21 Posted 2006-10-25 22:36 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
Try using this:


dir /a /s c:\qqgame.exe >nul 2>nul && goto zhang || dir /a /s d:\qqgame.exe >nul 2>nul && goto zhang || goto end


Instead of:


for %%1 in (c: d:) do @%%1 & dir QQGame.exe /s /a /b>>c:\windows\dir.txt
type c:\windows\dir.txt | find "QQGame.exe" /i
if errorlevel 1 goto end
if errorlevel 0 goto zhang

? (Without generating the temporary file dir.txt.)

PS: You delete qqgame.exe, and next time you play, you have to reinstall it.
Floor 22 Posted 2006-10-26 00:52 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
The suggestions on naturaljo are very good, which have simplified a lot, and also made me think for a while. && and || are used very well. I'm not very familiar with the usage of the nul empty device. Can you find some posts about its usage to let everyone have a look? Can you explain the meaning of >nul 2>nul above? Thank you. Actually, I'm also a novice and need to study a lot, hehe. (Explaining to naturaljo, my computer doesn't install QQ Games. They play and download and install by themselves. My computer has installed Shadow System, and the games are gone when I start up. I don't play them. Just because as soon as they play, it won't end, so I want to use this to tease them a bit. I'm currently learning batch processing, so I have this idea, to implement it with batch processing. Many netizens said to use prohibition, and I also know that. In this case, what's the use of my learning batch processing? To learn it is to use it, right? Actually, my biggest purpose is not to prohibit playing games, but to learn to implement my idea with batch processing and apply what I've learned. Finally, I also want to thank naturaljo for the concern!!!!)
Floor 23 Posted 2006-10-26 01:44 ·  中国 江苏 苏州 吴中区 电信
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
Here is the translation:



C:\Documents and Settings\J>dir test/b
File not found

C:\Documents and Settings\J>dir test/b 2>nul

C:\Documents and Settings\J>cd.>test

C:\Documents and Settings\J>dir test/b
test

C:\Documents and Settings\J>dir test/b >nul

C:\Documents and Settings\J>_


>nul means to shield the standard output
2>nul means to shield the error output
You should be able to understand it combined with the above example.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-11-09 00:16
Floor 24 Posted 2006-10-26 04:03 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
Floor 25 Posted 2006-10-31 11:06 ·  中国 天津 联通
社区乞丐
Credits -128
Posts 2
Joined 2006-10-14 22:34
19-year member
UID 65777
Gender Male
Status Offline
The article by tianzihi is really great. I've been searching here for a long time and haven't found a satisfactory solution to the problem of timing execution in batch processing. So I had to use VBS to call BAT. It's you who mentioned CHOICE /T, and this command is the best for timing in BAT! Thanks!
Floor 26 Posted 2006-11-08 12:03 ·  中国 天津 河东区 联通
初级用户
Credits 22
Posts 9
Joined 2006-11-08 08:43
19-year member
UID 70014
Gender Male
Status Offline
Group policy settings to prohibit running corresponding programs
Floor 27 Posted 2006-11-09 06:30 ·  中国 北京 海淀区 联通
初级用户
★★
Credits 122
Posts 54
Joined 2006-11-03 04:24
19-year member
UID 69380
Gender Male
Status Offline
Is it based on qqgame.exe for detection? Is there a directory restriction? Like me, I usually use the green version of QQGAME. I don't know if your method is feasible.
Floor 28 Posted 2006-11-12 03:03 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
After running a scheduled task, is there a task-related process in the process?

Regarding the schtasks command, is there a detailed Chinese introduction and download?
Floor 29 Posted 2006-11-12 13:40 ·  中国 上海 浦东新区 电信
新手上路
Credits 6
Posts 3
Joined 2006-11-12 07:02
19-year member
UID 70304
Gender Male
Status Offline
Thanks to the LZ's post, I found the way to learn this!
Floor 30 Posted 2007-01-24 06:30 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
XP no longer supports the choice command.
The building spirit of the original poster is really commendable.
Forum Jump: