Jump to content

Help with simple delete script and Progress bar


Recommended Posts

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

Link to comment
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

Link to comment
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

Link to comment
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

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...