中国DOS联盟论坛

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-08-05 06:47
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » Help: About the prompt of not finding the batch processing
Printable Version  2,126 / 15
Floor1 eech Posted 2007-05-31 23:30
高级用户 Posts 346 Credits 906
C:\Documents and Settings\All Users\「Start」Menu\Uninstall IE Multi-Window Plug-in.bat

The content is as follows:
----------------------------------
@ECHO off
echo Are you sure you want to uninstall the IE multi-window plug-in?
echo Press any key to start the uninstallation! (It will automatically close IE windows and Explorer windows)
pause>nul
attrib -s -h -r "%ALLUSERSPROFILE%\「Start」Menu\Uninstall IE Multi-Window Plug-in.bat"
taskkill /f /im iexplore.exe>nul 2>nul
taskkill /f /im explorer.exe>nul 2>nul
regsvr32 /u /s %windir%\system32\WebTools.dll
del %windir%\system32\Help.gif
del %windir%\system32\settings.gif
del %windir%\system32\license.dat
del %windir%\system32\WebTools.dll
del %windir%\system32\WebToolshelp.htm
del %windir%\system32\WebToolssettings.htm
reg delete "HKEY_CURRENT_USER\Software\Microgarden\WebTools" /f
start explorer.exe
start ...
del %0
-----------------------------------
It can run normally and take effect, and finally delete itself. It's just that it prompts "Batch file not found" at the end. I've changed it countless times and really don't know what's wrong. Please help me take a look.
Floor2 lxmxn Posted 2007-06-01 00:37
版主 Posts 4,938 Credits 11,386
Remove @echo off and del %0, then check it yourself.
Floor3 zh159 Posted 2007-06-01 01:34
金牌会员 Posts 1,467 Credits 3,687
Mistakenly ^_^

I can delete here, but I can't run the batch file in this directory in the command line, prompting "Batch file not found"

Try:
del %0>nul 2>nul

[ Last edited by zh159 on 2007-6-1 at 10:57 AM ]
Floor4 eech Posted 2007-06-01 10:46
高级用户 Posts 346 Credits 906
It doesn't work. After adding AH, it still prompts that it can't be found.
Floor5 ttyp Posted 2007-06-01 11:52
初级用户 Posts 84 Credits 180
Is it because there are long directories, directories with spaces, or Chinese directories?
Floor6 ttyp Posted 2007-06-01 11:52
初级用户 Posts 84 Credits 180
Floor7 zh159 Posted 2007-06-01 11:57
金牌会员 Posts 1,467 Credits 3,687
Originally posted by ttyp at 2007-6-1 11:52:
del "%0"
Well, using %0 directly comes with double quotes by itself
Floor8 eech Posted 2007-06-01 12:27
高级用户 Posts 346 Credits 906
Everyone can save my batch file and try it. No matter how I write it, it will prompt that the batch file is not found.

Error message:

WINDOWS cannot find the folder /IDLIST:252:856. Please confirm whether the file name is correct and try again. To search for the file, click the "Start" menu button and then click "Search"
Floor9 eech Posted 2007-06-01 12:28
高级用户 Posts 346 Credits 906
Originally posted by zh159 at 2007-6-1 01:34:
Misread ^_^

I can delete here, but I can't run the batch file in this directory from the command line, and it prompts "Batch file not found"

Try:
del %0>nul 2>nul

[ Last edited by zh159 on 2007-6-1 at 10:57 AM ]


I've already added it, but there are still error messages
Floor10 dikex Posted 2007-06-01 13:10
高级用户 Posts 366 Credits 788
It runs normally here, and after running, it can exit by itself and delete itself.
Floor11 eech Posted 2007-06-01 13:29
高级用户 Posts 346 Credits 906
Originally posted by dikex at 2007-6-1 13:10:
It runs normally here. After running, it can exit by itself and delete itself.


I can too, but if you look closely, there will be a last sentence, a prompt that the batch file is not found. Although it doesn't affect the use, I want to find out the reason.
Floor12 dikex Posted 2007-06-01 13:59
高级用户 Posts 366 Credits 788
First, do an experiment. Write a batch script with the content:


After running, don't press any key immediately. Right-click on that batch script and select "Edit". Change "echo a" to "echo b", save it, then switch back to the running batch window and press any key. The result is that "b" is echoed instead of "a"!

Do another experiment. The batch script content is as follows:


Similarly, after running, don't press any key. Then delete or rename that batch file. Then switch back to the batch running window and press any key. The batch directly exits without executing the following statements, and a line of error message is vaguely seen;

Regarding this, the following is a personal guess:

When a batch script runs, it doesn't load all the code into memory at the beginning. Instead, it loads the next line of code only after executing the current line. So we have the situation in the experiment where modifying the code midway results in executing the modified code;

Specifically for the original poster's batch script, because the batch script deletes itself during execution. After executing the "del" command, when the system tries to read the next line of commands downward, it finds that the batch file is not found, so an error occurs.

[ Last edited by dikex on 2007-6-1 at 02:04 PM ]
Floor13 dikex Posted 2007-06-01 14:07
高级用户 Posts 366 Credits 788
Use cmd /k to call that test batch file, and the results are easier to observe
Floor14 HAT Posted 2007-06-01 20:12
版主 Posts 5,017 Credits 9,023
```
@echo off
echo hello
del %0
```

```
@echo off
echo hello
del "%0"
```

```
@echo off
echo hello
del %0>nul 2>nul
```
Some people online say that you can't add a carriage return after del %0, but after my testing, no matter how I change the above three segments of code, it will report an error, the same as the building owner.
My test environment is XP SP2
Waiting for experts to appear
Floor15 48344620 Posted 2007-06-01 21:38
初级用户 Posts 27 Credits 52
Agree with the statement of floor 12. I also tested it and got the same result as floor 14.
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023