Re zwzhb:
Actually, the batch script that triggers an event based on the number of startups is already close to the detection mechanism of a virus. But in fact, it's very simple to implement, and there are many solutions even under DOS. So, it was the first module I completed when I was researching batch pseudo-viruses in the early days.
Just for the purpose of controlling the spread speed of dangerous technologies, I can only provide a general idea, not the source code. In fact, it's very hard to find my past source code. The premise of judging whether to trigger an event based on the number of startups is to measure the number of startups. There are various algorithms to obtain and detect this number.
For example, the solution of bagpipe and Brother 3742668 involving saving the number of startups to a variable and incrementing it one by one. Under DOS, because it's complicated to add and subtract environment variables, this method can be slightly modified. Convert the number of startups into the number of lines in a temporary file (detectable with find) or the total number of bytes (usually 3 times the number of times) for saving and detection.
Or, you can also use the stack method in Brother 3742668's second solution to save the number of startups in the file name. When actually implementing it, you don't need to rename and stack line by line. A simple command line loop can complete this task.
Re bagpipe:
I feel that your code affects the simplicity and readability of the program because of taking care of the sequentiality in the program structure.
For example, if not exist c:\test.txt goto A and if exist c:\test.txt goto D have code redundancy. And the four label segments A, B, C, D and the corresponding goto also make the program structure complicated. After careful consideration, I think these labels can all be omitted because the existence judgment of c:\test.txt can be completed at the same time by slightly modifying the for statement, and other jumps and branches can also be simplified.
In addition, brother uses the variable i to save the incremented number 1, which should have special considerations, but I can't guess it.
Finally, I remember that brother once posted a signature picture of "bagpipe musical note letters". Can you give me a copy for collection? If you are interested, please send it directly to my email. Thank you very much!
Re 3742668:
Is it more convenient to directly write the set /a sentence into the temporary batch file for saving? For example:
if exist _bootnum.cmd (call _bootnum.cmd) else set bootnum=1
echo set /a bootnum=%bootnum%+1>_bootnum.cmd
if bootnum equ 50 goto .....
To Wengier:
This topic can be transferred to "Batch Processing Room" for further discussion. Please help transfer it a little.
[
Last edited by willsort on 2006-5-13 at 17:23 ]