Originally posted by lxmxn at 2006-10-28 13:09:
It is not difficult to see that the above batch processing written by brother willsort needs to be run in the root directory of the system disk, and there is no statement to delete the "boot.ini" file in this code. But the following sentence makes me question: "copy %temp%\boot.new boot.ini>nul 2>nul". Here, it will copy "%temp%\boot.new" to the current working directory, that is, to the root directory of the system disk, and change the file name to "boot.ini". At this time, there is already a "boot.ini" file in the root directory of the system disk. At this time, the copy command will ask you whether to rewrite the original "boot.ini" file. However, brother willsort simply adds the " >nul 2>nul" shielding statement at the back. In this way, the system seems to be deadlocked in a questioning state. Of course, the CMD window has no prompts. This obviously does not achieve our purpose, and the result is obviously a copy failure.
This is a matter of experience.
If you have actually tested this code,
you will understand the mystery.
There is a switch /y for copy to control whether to overwrite the file with the same name.
In the command line, this switch is off by default.
In batch processing, this switch is on by default.
So in batch processing, copy does not need the /y switch.
Unless there is an environment variable copycmd and /-y value is specified.
