Answer the question
In order to leave comments, you need to log in
How to write a bat nickname with "self-destruction"?
Hello, I'm slowly delving into "computer science".
And I wanted to write something like a virus.
It doesn't really do anything, it just exists.
And after the execution of the "virus", the bat-nick should start.
The purpose of this batch file is to destroy the entire directory in which it is located (instead of itself).
I tried but this is what I got:
Процесс не может получить доступ к файлу, так как этот файл занят другим процессом
@echo off
rd /s /q %cd%
pause
Answer the question
In order to leave comments, you need to log in
You cannot delete a directory if it (or its subdirectories) is a worker for some process. Before rd
trying to change the working directory:
cd \
rd /s /q %0\..
For about the same, I use nircmd .
The batch file runs a script for nircmd that removes garbage from the folder, and then deletes the script, the batch file and the nircmd program itself.
Del_AppleTrash.bat
@echo off
echo Удаление огрызочного мусора
nircmd.exe elevatecmd script Del_AppleTrash.ncl
execmd del ".DS_Store" /F /S
execmd del "Del_AppleTrash.ncl" /F
execmd del "nircmd.exe" /F
execmd del "Del_AppleTrash.bat" /F
dig in the direction of
start "rd / s / q % cd%"
I have nowhere to try, but if you add a delay there, it should work better
Deleting yourself:
Deleting everything in the launch folder:
Deleting the launch folder:
SET AA=%CD%
CD ..\
CMD /C RD /S /Q %AA%
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question