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 13:26
中国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,944 Replies 36
Original Poster Posted 2006-10-15 10:45 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
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 ]
Floor 2 Posted 2006-10-15 10:49 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline

I can't do it
Floor 3 Posted 2006-10-15 10:49 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Just set the permissions of the folder.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 4 Posted 2006-10-15 11:07 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
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 ]
Floor 5 Posted 2006-10-15 11:09 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
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:


Windows Registry Editor Version 5.00


"RestrictRun"=dword:00000001


"1"="regedit.exe"
"2"="notepad.exe"
"3"="explorer.exe"


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.
Floor 6 Posted 2006-10-15 11:14 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
Please let moderator 3742668 post the batch file or script, I want to try it, thank you!!
Floor 7 Posted 2006-10-15 11:55 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  The poster can try the following code, save it as a.reg file, and double-click to run it to achieve your purpose.

Windows Registry Editor Version 5.00



"1"="poco.exe"
"2"="qqgame.exe"
"3"="qq.exe"



  You can add the programs you don't want to run one by one above.
Floor 8 Posted 2006-10-16 00:03 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
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
Floor 9 Posted 2006-10-16 00:07 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Just prohibit illegal programs is okay
Floor 10 Posted 2006-10-16 04:43 ·  中国 江苏 南京 电信
高级用户
★★
Credits 623
Posts 214
Joined 2006-09-22 20:48
19-year member
UID 63387
Status Offline
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)
Floor 11 Posted 2006-10-16 04:50 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by tianzizhi at 2006-10-16 04:43:
I want to learn a new way of thinking and implement it with the knowledge I've gained. The process of thinking and exploring is very interesting. If any of the experts have other wonderful ideas, please post them for everyone to learn!
(Don't just think about how to ban...

Hehe
Floor 12 Posted 2006-10-16 05:28 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Bump
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 13 Posted 2006-10-16 05:37 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

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.


Floor 14 Posted 2006-10-21 06:50 ·  中国 黑龙江 牡丹江 中移铁通
初级用户
Credits 71
Posts 34
Joined 2006-09-15 02:15
19-year member
UID 62611
Status Offline
Hi! Hi!

This schtasks command

I should also study this command well, thank you for the reminder.
Floor 15 Posted 2006-10-25 10:35 ·  中国 湖北 武汉 江夏区 电信
初级用户
Credits 31
Posts 15
Joined 2006-08-18 18:02
19-year member
UID 60803
Gender Male
Status Offline
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.
Forum Jump: