Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch to delete files on reboot  (Read 10448 times)

0 Members and 1 Guest are viewing this topic.

Mere_Mortal

  • Guest
Batch to delete files on reboot
« on: January 22, 2005, 04:33:36 PM »
Greetings :)

I'm looking to create a batch file that will delete files on the next reboot. Not something that will just attempt to delete them there and then because the target file(s) will be in use.

In comparison, it would act like "KillBox" or "Remove on Boot", but I want batch code that will do this.

In addition, it would be nice if it would also apply to directories.

I honestly don't know if it's possible or whether this technique requires more advanced programming than DOS.

If you're really that interested, the reason for such is to remove multiple files associated with malware, particularly those of VX2/Look2Me.

If anyone knows and would tell me how I could achieve this, I'd be rather appreciative ;D

cs

  • Guest
Re: Batch to delete files on reboot
« Reply #1 on: January 24, 2005, 11:17:47 AM »
Do you want the files be deleted before the operating system starts? If not, adding the appropriate commands to the autoexec.bat or autoexec.nt should be sufficient.

Code: [Select]
del /f /s /q <path>
deletes all files and folders in <path>. Add this line to the appropriate autoexec or to a normal batch file which is called under Windows as scheduled task at startup or added to the startup folder.

Cheers,
[glb]cs[/glb]

Mere_Mortal

  • Guest
Re: Batch to delete files on reboot
« Reply #2 on: January 24, 2005, 02:42:34 PM »
I suppose that's an option. But it depends on whether it would run before the startup processes.

The principal is, that VX2/Look2Me infections create random DLL's upon each reboot, with the help of Registry entries. So the question is whether the script will delete the DLL's before they are renamed.

Although there are tools to deal with this infection, it's the idea that intruiges me.

I see one possibility is to use a batch file to copy or move the current autoexec to a temporary location and then replace it with a modified version. Then, per the scripting, the system will reboot and delete the files (hopefully) and after that, it will delete the modified autoexec and reinstate the original.

If you see what I mean, do you think that could be feasible?

Mere_Mortal

  • Guest
Re: Batch to delete files on reboot
« Reply #3 on: January 24, 2005, 04:21:09 PM »
Okay, this is the score so far...

I have created a folder : C:\Fix : Inside there is...

- RUN ME.BAT -
Quote
move C:\autoexec.bat "%windir%\temp"

move C:\fix\autoexec.bat C:\

start reboot.exe
- AUTOEXEC.BAT -
Quote
del /f /q  C:\fix\bad.txt

start C:\fix\replace.bat
- REPLACE.BAT -
Quote
del C:\autoexec.bat
move "%windir%\temp\autoexec.bat" C:\

There is also a rebooting utility, which upon execution reboots the system. Oh yes, and of course the target file, BAD.TXT

As you can see, the idea here is to put the current AUTOEXEC into the Windows\Temp directory and move the new one to C:\ and then reboot. AUTOEXEC would then run on reboot and firstly delete the text file. Then replace will be executed to restore the original AUTOEXEC.

Unfortunately, all goes well up until deleting the text file. I don't think AUTOEXEC.BAT is being loading per system boot. Any ideas?

aehbb



    Starter

    • Football highlights
  • Experience: Beginner
  • OS: Windows 7
Re: Batch to delete files on reboot
« Reply #4 on: March 05, 2015, 09:36:06 AM »
Okay, this is the score so far...

I have created a folder : C:\Fix : Inside there is...

- RUN ME.BAT -- AUTOEXEC.BAT -- REPLACE.BAT -There is also a rebooting utility, which upon execution reboots the system. Oh yes, and of course the target file, BAD.TXT

As you can see, the idea here is to put the current AUTOEXEC into the Windows\Temp directory and move the new one to C:\ and then reboot. AUTOEXEC would then run on reboot and firstly delete the text file. Then replace will be executed to restore the original AUTOEXEC.

Unfortunately, all goes well up until deleting the text file. I don't think AUTOEXEC.BAT is being loading per system boot. Any ideas?

I follow all steps but it doesn't work with me
I use Deep freeze if you went to use it this a link to download it http://so2.co/deep

patio

  • Moderator


  • Genius
  • Maud' Dib
  • Thanked: 1769
    • Yes
  • Experience: Beginner
  • OS: Windows 7
Re: Batch to delete files on reboot
« Reply #5 on: March 05, 2015, 10:21:13 AM »
Please Ignore the Post above...

Especially since the Topic is 9 years old...
" Anyone who goes to a psychiatrist should have his head examined. "

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Batch to delete files on reboot
« Reply #6 on: March 05, 2015, 11:34:32 AM »

I follow all steps but it doesn't work with me
I use Deep freeze if you went to use it this a link to download it http://so2.co/deep
Hmm.  Are you licensed to redistribute Deep Freeze without anyone paying for it?

patio

  • Moderator


  • Genius
  • Maud' Dib
  • Thanked: 1769
    • Yes
  • Experience: Beginner
  • OS: Windows 7
Re: Batch to delete files on reboot
« Reply #7 on: March 05, 2015, 04:16:09 PM »
He is now on our beloved Watch List...
" Anyone who goes to a psychiatrist should have his head examined. "