![]() |
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-11-10 12:15 |
47,815 topics / 349,930 posts / today 0 new / 48,291 members |
| 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. |
| Printable Version 14,345 / 36 |
| Floor16 NaturalJ0 | Posted 2006-10-25 20:27 |
| 银牌会员 Posts 533 Credits 1,181 | |
|
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." |
|
| Floor17 zrz000 | Posted 2006-10-25 21:07 |
| 初级用户 Posts 16 Credits 44 | |
|
Learned. Really good.
|
|
| Floor18 tianzizhi | Posted 2006-10-25 21:34 |
| 高级用户 Posts 214 Credits 623 | |
|
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 ] |
|
| Floor19 tianzizhi | Posted 2006-10-25 21:52 |
| 高级用户 Posts 214 Credits 623 | |
|
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!!! |
|
| Floor20 kingchain | Posted 2006-10-25 22:34 |
| 初级用户 Posts 57 Credits 133 | |
|
The spirit of the thread starter is worth me learning!
|
|
| Floor21 NaturalJ0 | Posted 2006-10-25 22:36 |
| 银牌会员 Posts 533 Credits 1,181 | |
|
Try using this:
Instead of: ? (Without generating the temporary file dir.txt.) PS: You delete qqgame.exe, and next time you play, you have to reinstall it. |
|
| Floor22 tianzizhi | Posted 2006-10-26 00:52 |
| 高级用户 Posts 214 Credits 623 | |
|
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!!!!)
|
|
| Floor23 NaturalJ0 | Posted 2006-10-26 01:44 |
| 银牌会员 Posts 533 Credits 1,181 | |
|
Here is the translation:
>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. |
|
| Floor24 tianzizhi | Posted 2006-10-26 04:03 |
| 高级用户 Posts 214 Credits 623 | |
| Floor25 bg888 | Posted 2006-10-31 11:06 |
| 社区乞丐 Posts 2 Credits -128 | |
|
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!
|
|
| Floor26 freeskych | Posted 2006-11-08 12:03 |
| 初级用户 Posts 9 Credits 22 | |
|
Group policy settings to prohibit running corresponding programs
|
|
| Floor27 jasonwang | Posted 2006-11-09 06:30 |
| 初级用户 Posts 54 Credits 122 | |
|
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.
|
|
| Floor28 anqing | Posted 2006-11-12 03:03 |
| 高级用户 Posts 413 Credits 859 | |
|
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? |
|
| Floor29 jxf123521 | Posted 2006-11-12 13:40 |
| 新手上路 Posts 3 Credits 6 | |
|
Thanks to the LZ's post, I found the way to learn this!
|
|
| Floor30 htysm | Posted 2007-01-24 06:30 |
| 高级用户 Posts 415 Credits 866 | |
|
XP no longer supports the choice command.
The building spirit of the original poster is really commendable. |
|
| Prev 1 2 3 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |