1.

Solve : delete file in batch?

Answer»

to del file name cracker.exe in all my partition and drives

i write this in .bat

@echo off
CD\
C:
del /a /s cracker.exe
D:
del /a /s cracker.exe
E:
del /a /s cracker.exe
F:
del /a /s cracker.exe

but sometimes this also will come out error "no disk"

can i make it shorter? so that no need type C: D: E: F: until Z:

Help pls....

i'm using sp2
Microsoft Windows XP [VERSION 5.1.2600]You can use a LOOP to test which drive letters actually exist on your system

Code: [Select]@echo off
REM remember where we are
set thisfolder=%CD%
for %%D in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
if exist "%%D:\" (
%%D:
cd %%D:\
del /a /s cracker.exe
)
)
REM go back to FOLDER where we started
cd /D %thisfolder%


tq very much : )



Discussion

No Comment Found