Jump to content

Count Deleted Files in Folders


Recommended Posts

 

I am making a script that needs to count the number of times a file in .exe and .vbs extension are deleted. I would like them to be displayed as a windows notification balloon. The script monitors a particular folder and deletes any .exe or .vbs that is created. Hence I need to count how many files have been deleted! Somebody help me?

Link to comment
Share on other sites

  • Moderators

Mateus_Terra,

Welcome to the AutoIt forums.

I suggest you need to monitor the folder in question using one of the available UDFs (search FileSystemMonitor and RDC) and then when one of the defined files is created in the folder you can delete it and add to the count. Sounds like a fun project , but out of interest why do you need to do it?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

3 minutes ago, Melba23 said:

Mateus_Terra,

Welcome to the AutoIt forums.

I suggest you need to monitor the folder in question using one of the available UDFs (search FileSystemMonitor and RDC) and then when one of the defined files is created in the folder you can delete it and add to the count. Sounds like a fun project , but out of interest why do you need to do it?

M23

This is a virus that is entering our company system, the virus enters the machine in .exe and .vbs format. I have already been able to delete them immediately and I am able to survive this way .. I wanted to implement the count of how many "viruses" it would be deleting.

Link to comment
Share on other sites

Look at my script. It's incredible that it seems to be solving my problem effectively.

 

while 1
$arquivovbs = "*.vbs"
$arquivoexe = "*.exe"

$iDeletevbs0 = FileDelete("C:\Totvs\jboss-4.2.3.GA\bin\"&$arquivovbs)
$ideleteexe0 = FileDelete("C:\Totvs\jboss-4.2.3.GA\bin\"&$arquivoexe)
$iDeletevbs1 = FileDelete("C:\Totvs\jboss-4.2.3.GA\client\"&$arquivovbs)
$ideleteexe1 = FileDelete("C:\Totvs\jboss-4.2.3.GA\client\"&$arquivoexe)
$iDeletevbs2 = FileDelete("C:\Totvs\jboss-4.2.3.GA\docs\"&$arquivovbs)
$ideleteexe2 = FileDelete("C:\Totvs\jboss-4.2.3.GA\docs\"&$arquivoexe)
$iDeletevbs3 = FileDelete("C:\Totvs\jboss-4.2.3.GA\lib\"&$arquivovbs)
$ideleteexe3 = FileDelete("C:\Totvs\jboss-4.2.3.GA\lib\"&$arquivoexe)
$iDeletevbs4 = FileDelete("C:\Totvs\jboss-4.2.3.GA\server\"&$arquivovbs)
$ideleteexe4 = FileDelete("C:\Totvs\jboss-4.2.3.GA\server\"&$arquivoexe)

WEnd

Link to comment
Share on other sites

  • Moderators

Mateus_Terra,

 I take it that you are doing something to prevent the infection rather then just deleting these files?

M23

Edit: And if you really want a count, just check the return value from the FileDelete call and add it to a counter:

$arquivovbs = "*.vbs"
$arquivoexe = "*.exe"

$iDeletevbs0 = 0
$ideleteexe0 = 0
$iDeletevbs1 = 0
$ideleteexe1 = 0
$iDeletevbs2 = 0
$ideleteexe2 = 0
$iDeletevbs3 = 0
$ideleteexe3 = 0
$iDeletevbs4 = 0
$ideleteexe4 = 0

While 1

    ; Add to the count each time a deletion occurs
    $iDeletevbs0 += FileDelete("C:\Totvs\jboss-4.2.3.GA\bin\" & $arquivovbs)
    $ideleteexe0 += FileDelete("C:\Totvs\jboss-4.2.3.GA\bin\" & $arquivoexe)
    $iDeletevbs1 += FileDelete("C:\Totvs\jboss-4.2.3.GA\client\" & $arquivovbs)
    $ideleteexe1 == FileDelete("C:\Totvs\jboss-4.2.3.GA\client\" & $arquivoexe)
    $iDeletevbs2 += FileDelete("C:\Totvs\jboss-4.2.3.GA\docs\" & $arquivovbs)
    $ideleteexe2 += FileDelete("C:\Totvs\jboss-4.2.3.GA\docs\" & $arquivoexe)
    $iDeletevbs3 += FileDelete("C:\Totvs\jboss-4.2.3.GA\lib\" & $arquivovbs)
    $ideleteexe3 += FileDelete("C:\Totvs\jboss-4.2.3.GA\lib\" & $arquivoexe)
    $iDeletevbs4 += FileDelete("C:\Totvs\jboss-4.2.3.GA\server\" & $arquivovbs)
    $ideleteexe4 += FileDelete("C:\Totvs\jboss-4.2.3.GA\server\" & $arquivoexe)

    Sleep(10) ; Not a bad idea to prevent the CPU frying

WEnd

 

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

2 hours ago, Melba23 said:

Mateus_Terra,

 I take it that you are doing something to prevent the infection rather then just deleting these files?

M23

Edit: And if you really want a count, just check the return value from the FileDelete call and add it to a counter:

$arquivovbs = "*.vbs"
$arquivoexe = "*.exe"

$iDeletevbs0 = 0
$ideleteexe0 = 0
$iDeletevbs1 = 0
$ideleteexe1 = 0
$iDeletevbs2 = 0
$ideleteexe2 = 0
$iDeletevbs3 = 0
$ideleteexe3 = 0
$iDeletevbs4 = 0
$ideleteexe4 = 0

While 1

    ; Add to the count each time a deletion occurs
    $iDeletevbs0 += FileDelete("C:\Totvs\jboss-4.2.3.GA\bin\" & $arquivovbs)
    $ideleteexe0 += FileDelete("C:\Totvs\jboss-4.2.3.GA\bin\" & $arquivoexe)
    $iDeletevbs1 += FileDelete("C:\Totvs\jboss-4.2.3.GA\client\" & $arquivovbs)
    $ideleteexe1 == FileDelete("C:\Totvs\jboss-4.2.3.GA\client\" & $arquivoexe)
    $iDeletevbs2 += FileDelete("C:\Totvs\jboss-4.2.3.GA\docs\" & $arquivovbs)
    $ideleteexe2 += FileDelete("C:\Totvs\jboss-4.2.3.GA\docs\" & $arquivoexe)
    $iDeletevbs3 += FileDelete("C:\Totvs\jboss-4.2.3.GA\lib\" & $arquivovbs)
    $ideleteexe3 += FileDelete("C:\Totvs\jboss-4.2.3.GA\lib\" & $arquivoexe)
    $iDeletevbs4 += FileDelete("C:\Totvs\jboss-4.2.3.GA\server\" & $arquivovbs)
    $ideleteexe4 += FileDelete("C:\Totvs\jboss-4.2.3.GA\server\" & $arquivoexe)

    Sleep(10) ; Not a bad idea to prevent the CPU frying

WEnd

 

rsrsrs I'm burning my head. I've never used this function.

Link to comment
Share on other sites

  • Moderators

Mateus_Terra,

Google tells me what "rsrsrs" is in Portuguese ("LOL") but to which function are you referring?

If you mean "+=" then please see this page in the Help file.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Mateus_Terra,

Delighted to hear it.

But when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

2 minutes ago, Melba23 said:

Mateus_Terra,

Delighted to hear it.

But when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.

M23

 

Soooooorry man.... 

Link to comment
Share on other sites

  • Moderators

Mateus_Terra,

Where have I mentioned FileFindFirstFile?

 And I would recommend TraySetToolTip rather then TrayTip - that way you only get the tip displaying if you hover over the tray icon rather than a permanent display.

And you still have not answered my question:

3 hours ago, Melba23 said:

I take it that you are doing something to prevent the infection rather then just deleting these files?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

On 03/04/2017 at 5:08 PM, Melba23 said:

Mateus_Terra,

Where have I mentioned FileFindFirstFile?

 And I would recommend TraySetToolTip rather then TrayTip - that way you only get the tip displaying if you hover over the tray icon rather than a permanent display.

And you still have not answered my question:

M23

I do not understand your question .. We're trying to figure out a way to prevent infection by yes, but even we can not and depend on the program's function in the meantime!

Link to comment
Share on other sites

  • Moderators

Mateus_Terra,

Stop using the "Quote" button to reply - you apologised for doing so in post #12 and here you are doing it again!

My question relates to your comment in post #11

On ‎03‎/‎04‎/‎2017 at 8:42 PM, Mateus_Terra said:

FileFindFirstFile  and TrayTip  Is it what I should use?

So I ask again - why do you bring FileFindFirstFile into it?  All you need to do to the script developed above is to add a TraySetToolTip so that you can see the current deletion count when you hover over the icon. But the content of such a tooltip is limited, so you might want to think of using something else - and my Toast & Notify UDFs (look in my sig for the links) are designed for exactly this type of thing. Display one of those each time a file is deleted and I think you have a good working solution. Let me know if you would like some help getting it all to work.

And I am delighted to hear you are working on removing the virus - a much better long-term solution.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba23, thanks for all your patience and attention. I'm new here and I still do not know how exactly the forum works, and has the translation question as well.So far all the scripts I've done have been without forum help, I've made scripts much more complex than this one, including a point of entry and exit register, which works very well. But this simple option to tell I'm stuck. Kkkkkk your help would be very welcome if possible for!

Link to comment
Share on other sites

Seria algo assim?

TraySetToolTip("Número de Vírus.exe deletados: "&$ideleteexe0+$ideleteexe1+$ideleteexe2+$ideleteexe3+$ideleteexe4&Chr(13)&"Número de Vírus.vbs deletados: "&$iDeletevbs0+$iDeletevbs1+$iDeletevbs2+$iDeletevbs3+$iDeletevbs4)

 

 

Link to comment
Share on other sites

  • Developers
4 minutes ago, Mateus_Terra said:

Seria algo assim?

Geen idee what je bedoeld want ik spreek geen portugees. ;)

Try English as that is in general much clearer for most of us.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Kkkkkk I'm getting crazy


Was it something like that?

TraySetToolTip ("Number of Viruses.exe Deleted:" & $ iDeletevbs0 + $ iDeletevbs1 + $ iDeletevbs2 + $ iDeletevbs3 + $ iDeletevbs4) $ & $ ideleteexe0 + $ ideleteexe2 + $ ideleteexe2 + $ ideleteexe3 + $ ideleteexe4 & Chr (13)

Link to comment
Share on other sites

  • Developers

Still unsure what the question is you have here.
You show a line of code containing syntax errors as there are spaces between the $ and the variable name.
So what about you use a couple more English words to describe the issue/question and show the total code snipped if possible.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...