Sign in to follow this  
Followers 0
Paulexander

Help with simple delete script and Progress bar

8 posts in this topic

I have created a basic script that will scan for and delete certain log files that our (stupid) VPN was dumping into the root of the C:\ drive. The basic script I created works in testing, however, some users have tens of thousands of these log files on their machine, and the deletion might take a few moments.

I would like to give my user's something to let them know the utility is still working along.

What can I add to this to get a working progress bar to show?

CODE
;-------------------------------------------

; Intro Message Box

;-------------------------------------------

$VAR1 = MsgBox ( 1, "Citrix SSLVPN Log Cleanup Utility", "Click OK to Continue with Citrix log scan and cleanup, or Cancel to Exit" )

If $VAR1 = 2 Then Exit

;-------------------------------------------

; Scan For files

;-------------------------------------------

If FileExists("C:\hooklog*") Then

MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "Citrix SSLVPN logs have been found, Click OK to clean them out.")

Else

MsgBox(4096,"Citrix SSLVPN Log Cleanup Utility", "You have no Citrix logs, Click Ok to Exit")

Exit

EndIf

;-------------------------------------------

; Delete Files

;-------------------------------------------

FileDelete ( "c:\hooklog*" )

;-------------------------------------------

; Double Check

;-------------------------------------------

If FileExists("C:\hooklog*") Then

MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "You still have excessive Citrix log files, Call HelpDesk for further assistance.")

Else

MsgBox(4096,"Citrix SSLVPN Log Cleanup Utility", "Your disk has been cleaned, Click Ok to Exit")

Exit

EndIf

Exit

Share this post


Link to post
Share on other sites



not tested******

#Include <File.au3>

;-------------------------------------------
; Intro Message Box
;-------------------------------------------
$VAR1 = MsgBox(1, "Citrix SSLVPN Log Cleanup Utility", "Click OK to Continue with Citrix log scan and cleanup, or Cancel to Exit")
If $VAR1 = 2 Then Exit
;-------------------------------------------
; Scan For files
;-------------------------------------------

If FileExists("C:\hooklog*") Then
    MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "Citrix SSLVPN logs have been found, Click OK to clean them out.")
Else
    MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "You have no Citrix logs, Click Ok to Exit")
    Exit
EndIf
;-------------------------------------------
; Delete Files
;-------------------------------------------
$FileList = _FileListToArray("c:\hooklog*")
If @error = 1 Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf

$Prog = (100 / $FileList[0])
$Progress = ProgressOn("Citrix SSLVPN Log Cleanup Utility", "Citrix SSLVPN logs are being removed.", "Please wait...")

For $x = 1 To $FileList[0]
    ProgressSet($Prog)
    FileDelete($FileList[$x])
    $Prog += $Prog
    Sleep(20)
Next

ProgressOff()
;-------------------------------------------
; Double Check
;-------------------------------------------
If FileExists("C:\hooklog*") Then
    MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "You still have excessive Citrix log files, Call HelpDesk for further assistance.")
Else
    MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "Your disk has been cleaned, Click Ok to Exit")
    Exit
EndIf

Exit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thanks, this is great, but I got an error:

==> Subscript used with non-Array variable.:

$Prog = (100 / $FileList[0])

$Prog = (100 / $FileList^ ERROR

This is where I get hung up, as I am learning this stuff as I go.

What do I need to know to fix this variable?

thanks

-paul

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

***nope

_FileListToArray() is not finding an error but...

what is the extension of these files ( what do they appear as

hooklog.txt

hooklog24,dat

hooklog-101.bak

?????

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

They are all Hooklog<number>.txt files:

hooklog0.txt

hooklog1.txt

hooklog2.txt

hooklog3.txt

hooklog4.txt

hooklog5.txt

hooklog6.txt

hooklog7.txt

hooklog8.txt

etc...

Share this post


Link to post
Share on other sites

TESTED _ WORKS ***************

#Include <File.au3>

;-------------------------------------------
; Intro Message Box
;-------------------------------------------
$VAR1 = MsgBox(1, "Citrix SSLVPN Log Cleanup Utility", "Click OK to Continue with Citrix log scan and cleanup, or Cancel to Exit")
If $VAR1 = 2 Then Exit
;-------------------------------------------
; Scan For files
;-------------------------------------------

If FileExists("C:\hooklog*") Then
    MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "Citrix SSLVPN logs have been found, Click OK to clean them out.")
Else
    MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "You have no Citrix logs, Click Ok to Exit")
    Exit
EndIf
;-------------------------------------------
; Delete Files
;-------------------------------------------
$Location = "c:\"
$FileList = _FileListToArray($Location)
If @error = 1 Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf

$Prog = (100 / (UBound($FileList)-1))
$Progress = ProgressOn("Citrix SSLVPN Log Cleanup Utility", "Citrix SSLVPN logs are being removed.", "Please wait...")
Sleep(500)
For $x = 1 To UBound($FileList)-1
    ProgressSet($Prog)
    If StringInStr($FileList[$x], "hooklog") Then FileDelete($Location & $FileList[$x])
    $Prog += $Prog
    Sleep(20)
Next
Sleep(500)
ProgressOff()
;-------------------------------------------
; Double Check
;-------------------------------------------
If FileExists("C:\hooklog*") Then
    MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "You still have excessive Citrix log files, Call HelpDesk for further assistance.")
Else
    MsgBox(4096, "Citrix SSLVPN Log Cleanup Utility", "Your disk has been cleaned, Click Ok to Exit")
    Exit
EndIf

Exit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Wow, thank you so much. It works indeed...That was very kind of you.

Now I have to figure out what the heck all that stuff means.

-Paul

Share this post


Link to post
Share on other sites

Welcome...

and good luck

8)


NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0