Solved

delete a folder ever 5 minutes

Posted on 2016-09-12
6
54 Views
Last Modified: 2016-09-13
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
0
Comment
Question by:NxJNY
  • 3
  • 2
6 Comments
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
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
0
 
LVL 2

Author Comment

by:NxJNY
Comment Utility
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"
0
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
Comment Utility
My guess would be that once the anti-malware utilities are running they have that folder "locked" or open for access and Windows can not remove it them.  Whent the BAT script runs (run it from a stand alone command prompt for a test) what error message does it display?

~bp
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 2

Author Comment

by:NxJNY
Comment Utility
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
0
 
LVL 23

Expert Comment

by:NVIT
Comment Utility
Maybe leave it as is?
- You have the log file.
- The folder does clear, albeit after a reboot.
0
 
LVL 2

Author Comment

by:NxJNY
Comment Utility
i used Robocopy - thanks for all your help

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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article will help you understand what HashTables are and how to use them in PowerShell.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now