surreal Posted July 23, 2012 Posted July 23, 2012 (edited) im trying to do the followingdelete 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.expandcollapse popupIf @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 ;==>_windowsXPi 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 July 23, 2012 by surreal
Scriptonize Posted July 24, 2012 Posted July 24, 2012 Hi, I've changed your code a bit. Take a look and see if it is of any help. Cheers, ScriptonizeDelFolderContent.au3 If you learn from It, it's not a mistake
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