Sign in to follow this  
Followers 0
surreal

filedelete error checking and splash

3 posts in this topic

#1 ·  Posted (edited)

im trying to do the following

delete all files in a folder, but if the user does not have permission to delete the files return an error message. (the files are different all the time) if the user can delete then display a splash screen during and then a success msg.

below is the code i have but im having problems with where to include the splashtexton and success msg.

it is deleting the files if they have access and it is displaying the error code if they do not have access. I may be just making this harder than it is.

If @OSVersion = "WIN_7" Then
_windows7()
Exit
Else
_windowsXP()
Exit
EndIf
Func _windows7()
$sDir = "C:ProgramDataFolder"
$sFiles = "*.*"
$aFiles = StringSplit($sFiles, ",")
For $j = 1 To $aFiles[0]
$i = 50
While $i > 0
If StringLeft($aFiles[$j], 1) = "" Then
If DirRemove($sDir & $aFiles[$j]) Then ExitLoop
If FileExists($sDir & $aFiles[$j] & "*.*") Then
     If Not FileDelete($sDir & $aFiles[$j] & "*.*") Then
     MsgBox(262160, "Program", "You do not have the correct permissions. (Please contact the Server Desk)")
     ExitLoop
     EndIf
EndIf
Else
If FileDelete($sDir & '' & $aFiles[$j]) Then ExitLoop
EndIf
Sleep(100)

$i -= 1
If $i = 0 Then
MsgBox(262160, "Program", "You do not have the correct permissions. (Please contact the Server Desk)")
ExitLoop
EndIf
WEnd
Next
EndFunc ;==>_windows7
Func _windowsXP()
$sDir = "C:Documents and SettingsAll UsersApplication DataFolder"
$sFiles = "*.*"
$aFiles = StringSplit($sFiles, ",")
For $j = 1 To $aFiles[0]
$i = 50
While $i > 0

If StringLeft($aFiles[$j], 1) = "" Then
If DirRemove($sDir & $aFiles[$j]) Then ExitLoop
If FileExists($sDir & $aFiles[$j] & "*.*") Then
     If Not FileDelete($sDir & $aFiles[$j] & "*.*") Then
     MsgBox(262160, "Program", "You do not have the correct permissions. (Please contact the Server Desk)")
     ExitLoop
     EndIf
EndIf
Else
If FileDelete($sDir & '' & $aFiles[$j]) Then ExitLoop
EndIf
$i -= 1
If $i = 0 Then
MsgBox(262160, "Program", "You do not have the correct permissions. (Please contact the Server Desk)")
ExitLoop
EndIf
WEnd
Next
EndFunc ;==>_windowsXP

i want to included:

SplashTextOn("Program", "Clearing Cache. Please Wait...", 325, 45, -1, -1, 2, "", 10)
Sleep(2000)
SplashOff()
MsgBox(0, "Program", "Cache has been cleared.")

thank you everyone for your help.

d@ve

Edited by surreal

Share this post


Link to post
Share on other sites



Hi,

I've changed your code a bit.

Take a look and see if it is of any help.

Cheers,

Scriptonize

DelFolderContent.au3


If you learn from It, it's not a mistake

Share this post


Link to post
Share on other sites

  • thank you Scriptonize

d@ve

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