![]() |
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-09-15 12:59 |
47,812 topics / 349,917 posts / today 0 new / 48,268 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 13,753 / 36 |
| Floor1 tianzizhi | Posted 2006-10-15 10:45 |
| 高级用户 Posts 214 Credits 623 | |
|
I don't want others to play QQ games on my computer, and I'm too embarrassed to say it directly. But I want to prevent QQ games from running after installing them. Here's my idea: search for the main program of the game qqgame.exe on my computer. As soon as I find it, delete it immediately, so that QQ games can't be played. So I'm asking for a batch file that resides in memory. As soon as it finds the qqgame.exe file, it deletes it immediately. But it's required that this batch file doesn't occupy too much CPU. My CPU is slow. Please, all you experts, help. Thank you!
[ Last edited by tianzizhi on 2006-10-15 at 11:42 ] |
|
| Floor2 zh159 | Posted 2006-10-15 10:49 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
![]() I can't do it ![]() |
|
| Floor3 electronixtar | Posted 2006-10-15 10:49 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
Just set the permissions of the folder.
|
|
| Floor4 tianzizhi | Posted 2006-10-15 11:07 |
| 高级用户 Posts 214 Credits 623 | |
|
I only have an administrator account and don't want to use permission settings. Moreover, I can't be sure of the installation location of the game directory. If the C drive can't be installed, I can change to another disk, so this method doesn't work very well. I still want a batch program that can meet the requirements. Please, experts, use your brains. Thanks!!!!!!!!!!!
[ Last edited by tianzizhi on 2006-10-15 at 11:09 ] |
|
| Floor5 3742668 | Posted 2006-10-15 11:09 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
Using a script can indeed meet the building owner's requirements, but the building owner also said to take into account system performance, so it is recommended that the building owner implement it by modifying the registry. For example:
Save the above characters to "Prohibit Program Execution.reg", then double-click to import the registry. Then end explorer.exe and start explorer immediately, and only regedit.exe, notepad.exe, and explorer.exe can be run. If you have other programs that need to be run, then add the number and program path in turn below. If you think the above method is not quite appropriate, you can also use a vbs script, but it will cost about nearly 7MB of memory. |
|
| Floor6 tianzizhi | Posted 2006-10-15 11:14 |
| 高级用户 Posts 214 Credits 623 | |
|
Please let moderator 3742668 post the batch file or script, I want to try it, thank you!!
|
|
| Floor7 lxmxn | Posted 2006-10-15 11:55 |
| 版主 Posts 4,938 Credits 11,386 | |
|
The poster can try the following code, save it as a.reg file, and double-click to run it to achieve your purpose. You can add the programs you don't want to run one by one above. |
|
| Floor8 tianzizhi | Posted 2006-10-16 00:03 |
| 高级用户 Posts 214 Credits 623 | |
|
The above experts' registry solutions are feasible, but not what I most want. I haven't got what I most want yet. After more than a day of my little by little exploration, I finally found the solution I want. Here, I, the younger brother, would like to announce my exploration process to everyone for everyone's study. Please give your advice if there is anything wrong.
Recently I'm learning batch processing and am very interested in it, so I insist on making it realize my idea. I want this program to stay in memory and monitor the existence of files like qqgame.exe at any time. If there is any, delete it immediately. At first, I thought the directory was on drive C. The command used is: @echo off if exist c:\"program files"\tencent\qqgame\qqgame.exe del c:\"program files\tencent\qqgame\qqgame.exe (That pair of double quotes was what I just thought of after fumbling for a long time. Without them, it would keep prompting: The system cannot find the path. I was depressed for a long time. Could it be that the directory level is too much? Then I did an experiment on drive D. As a result, no matter how many directories there are, the path can be found. Suddenly I remembered that "programe files" is two words. Is it because of this? First I added single quotes, it didn't work. Then I added double quotes, it worked. I was very happy) Although this works, there are two problems: one is that it is not monitoring at any time, and the other is that the directory is determined too rigidly. It won't work if the directory is changed. To improve it, I also used the for command: @echo off for %%1 in (c: d:) do @del %%1\qqgame*.* /s /a I thought about how to execute this command all the time. I thought of looping again and used the following command: @echo off :zhang for %%1 in (c: d:) do @del %%1\qqgame*.* /s /a goto zhang Then I executed it on my computer Oh my god, my CPU was used up by it. That won't do. It's an infinite loop. I have to change another way. I also thought about being able to make for %%1 in (c: d:) do @del %%1\qqgame*.* /s /a execute regularly. Then the CPU can have a rest. I thought of the at command. I checked with at /? and then my hope was gone. Its minimum unit is day. I can't execute it once a day. Forget it. Change again. I used help to see if there were other good commands. Finally I found the schtasks command. This command should be unique to Windows 2003. Other systems seem not to have it. Its use is really too powerful. It is hundreds of times stronger than at. The following is a little information attached: Schtasks Arrange commands and programs to run regularly or at a specified time. Add tasks to the plan, delete tasks from it, start and stop tasks as needed, and display and change scheduled tasks. To view the command syntax, click the following commands: ? schtasks create ? schtasks change ? schtasks run ? schtasks end ? schtasks delete ? schtasks query schtasks create Schedule a task. Schtasks uses different parameter combinations for various schedule types. To view the combined syntax for creating a task or to view the syntax for creating a task using a specific schedule type, click one of the following options. ? Combined syntax and parameter description ? The scheduled task runs every N minutes ? The scheduled task runs every N hours ? The scheduled task runs every N days ? The scheduled task runs every N weeks ? The scheduled task runs every N months ? The scheduled task runs on specified days of the week ? The scheduled task runs on the specified week of the month ? The scheduled task runs on a specific date of the month ? The scheduled task runs on the last day of the month ? The scheduled task runs once ? The scheduled task runs every time the system starts ? The scheduled task runs when the user logs on ? The scheduled task runs when the system is idle ? The scheduled task runs now ? The scheduled task runs with different permissions ? The scheduled task runs with system permissions ? The scheduled task runs multiple programs ? The scheduled task runs on a remote computer Combined syntax and parameter description Syntax Schtasks /create /sc ScheduleType /tn TaskName /tr TaskRun User ]] User | System}] | *] ] ] After reading for a long time, I used the following command: schtasks /create /u Username /p Password /sc minute /mo 1 /tn "Immediate Deletion" /tr d:\a.bat The content of a.bat is: @echo off for %%1 in (c: d:) do @del %%1\qqgame*.* /s /a It seemed to work, but I also had a requirement. Its minimum interval time is 1 minute. I think it's too long. I want it to execute once every 15 seconds. Let's put this aside first. I looked for it again. I also checked for a while and found the /t parameter in the choice command. The function of /t is the number of seconds to pause before making the default selection. Its unit is seconds. This is exactly what I want. Ha ha, the opportunity came. I thought of the following command: @echo off :zhang for %%1 in (c: d:) do @del %%1\qqgame*.* /s /a choice /t 15 /d y goto zhang I saved it as a.bat After opening it, I found it was a window and couldn't disappear. I wanted it to run in the background. I looked for relevant information. I thought that using a vbs script was good. Then I wrote the following script: set ws=WScript.CreateObject("WScript.Shell") ws.Run "d:\a.bat",0 Saved as b.vbs Then I ran it again. Ha ha, it succeeded. It runs in the background. It checks whether there are files like qqgame*.* in the machine every 15 seconds. If there are, it deletes them immediately. Finally my wish was realized. Later I searched on the Internet and found another method. I didn't try it. I don't know if it works: @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, you can adjust it yourself as needed set /a next_minute=%%j+1 set /a next_hour=%%i 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 ) ) at !next_hour!:!next_minute! c:\settimerun.bat rem Here is the specific command to be executed, you can adjust it yourself as needed copy c:\windows\system32\notepad.exe d:\notepad.exe endlocal @echo on |
|
| Floor9 vkill | Posted 2006-10-16 00:07 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
Just prohibit illegal programs is okay
|
|
| Floor10 tianzizhi | Posted 2006-10-16 04:43 |
| 高级用户 Posts 214 Credits 623 | |
|
I want to learn is a new way of thinking, and use what I have learned to implement it. The process of thinking and exploring is very interesting. All you experts, if you have other wonderful ideas, post them for everyone to learn!
(Don't just think about how to prohibit it. Think from another angle. Even if it is installed, but if any of its files are damaged, or its original path is changed, or the file is renamed, it still can't run, right? How to achieve these? Everyone usually think more, change the angle to think, you will find that your thinking is much more flexible) |
|
| Floor11 vkill | Posted 2006-10-16 04:50 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
Originally posted by tianzizhi at 2006-10-16 04:43: Hehe |
|
| Floor12 redtek | Posted 2006-10-16 05:28 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Bump
|
|
| Floor13 lxmxn | Posted 2006-10-16 05:37 |
| 版主 Posts 4,938 Credits 11,386 | |
Finally, I found the schtasks command. This command should be unique to Windows 2003, and it seems that other systems don't have it. Its function is really too powerful, hundreds of times stronger than at. This schtasks command is not unique to Windows 2003. I also have it on my Windows XP sp2. I should really study this command well. Thank you for the reminder. |
|
| Floor14 yiping1973 | Posted 2006-10-21 06:50 |
| 初级用户 Posts 34 Credits 71 | |
|
Hi! Hi!
This schtasks command I should also study this command well, thank you for the reminder. |
|
| Floor15 sanhu35 | Posted 2006-10-25 10:35 |
| 初级用户 Posts 15 Credits 31 | |
|
From LZ's post, I saw LZ's growth.
I feel that my understanding of batch processing has also grown a bit. LZ, can I have your QQ? My QQ is 37730533. You can add me too. PS: For batch processing, I just know this much. |
|
| 1 2 3 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |