Paulexander Posted January 25, 2007 Posted January 25, 2007 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
Valuater Posted January 25, 2007 Posted January 25, 2007 not tested****** expandcollapse popup#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)
Paulexander Posted January 25, 2007 Author Posted January 25, 2007 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
Valuater Posted January 25, 2007 Posted January 25, 2007 (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 January 25, 2007 by Valuater
Paulexander Posted January 25, 2007 Author Posted January 25, 2007 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...
Valuater Posted January 25, 2007 Posted January 25, 2007 TESTED _ WORKS *************** expandcollapse popup#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)
Paulexander Posted January 25, 2007 Author Posted January 25, 2007 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now