Link to home
Start Free TrialLog in
Avatar of IT Guy
IT Guy

asked on

delete a folder ever 5 minutes

looking for a script to delete a folder in C:\Windows every 5 minutes. i do have a script but it seems its only successful after the PC reboots

OS : Win 8 & Win 10
Avatar of Bill Prew
Bill Prew

What is the script you are using currently?

And are you using Windows Scheduler to run it every 5 minutes, that would seem like the most straight forward approach.

~bp
Avatar of IT Guy

ASKER

so here is my little story

we have malwarebytes anti-ransomware which scans our computers but malwarebytes do not have a console as yet for this product so there is no alerting if we get infected however the anti-ransomware produces a local log file that we can read through to check if we got infected.

we are trying to leverage IBM Bigfix to perform this action by creating bat script to move the file to a temp location then delete the file.

here is the script

echo off
RD /S /Q "C:\Windows\Ransomware"
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IT Guy

ASKER

i have a script that copies the log file to a temp location and another that reads the log file

now i need one to delete the log file :)


Copy the log file

@echo off
set Src=C:\ProgramData\Malwarebytes\MBAMService\logs\MBAMSERVICE.LOG
set Tgt=C:\Windows\Ransomware
for /f "tokens=*" %%a in ("%Src%") do (
   xcopy "%Src%" "%Tgt%\%%~na\" /e
Maybe leave it as is?
- You have the log file.
- The folder does clear, albeit after a reboot.
Avatar of IT Guy

ASKER

i used Robocopy - thanks for all your help

robocopy.exe /Mir 'C:\ProgramData\Malwarebytes\MBAMService\logs' 'C:\Windows\Ransomware\MBAMSERVICE'"