TwoCanoe Posted February 11, 2025 Posted February 11, 2025 Hello again, I am having trouble deleteting some simple log files. Here is my very basic script: ; Remove read-only attribute FileSetAttrib(@LocalAppDataDir & "\Razer\RazerAppEngine\User Data\Logs\*.log", "-R") ; Delete all log files FileDelete (@LocalAppDataDir & "\Razer\RazerAppEngine\User Data\Logs\*.log") Four of the log files are in use, so I don't expect those files to be deleted. Of the other log files, some are deleted and some are not. I have tried adding '#RequireAdmin', but make no difference. I can delete the files manually in explorer without issue (except for the 4 locked files). Any thoughs?
Nine Posted February 11, 2025 Posted February 11, 2025 Of those that are not deleted, what are their attributes ? You may try FileRecycle instead of FileDelete... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
TwoCanoe Posted February 11, 2025 Author Posted February 11, 2025 (edited) Hi Nine, Just tried FileRecycle, same effect. All files have normal attributes. I added FileSetAttrib just in case. I also added this line to the begining of the script, as a test: FileOpen(@LocalAppDataDir & "\Razer\RazerAppEngine\User Data\Logs\TEST.log", 1) Even the created TEST.log file is not being deleted. I have checked file and folder permissions, full access all round. I also just made a quick batch file to compare: @echo off DEL /Q "C:\Users\%username%\AppData\Local\Razer\RazerAppEngine\User Data\Logs\*.log" 1>NUL 2>&1 The batch file works perfectly. Edited February 11, 2025 by TwoCanoe More info
Solution Nine Posted February 11, 2025 Solution Posted February 11, 2025 Try gathering all logs file into an Array with _FileListToArray, then delete files individually. I don't know how FileDelete works. Maybe it is stopping on the first issue (locked file). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
TwoCanoe Posted February 11, 2025 Author Posted February 11, 2025 An array works perfectly! #include <File.au3> Local $array = _FileListToArray(@LocalAppDataDir & "\Razer\RazerAppEngine\User Data\Logs\", "*.log") For $i = 1 to $array[0] FileDelete (@LocalAppDataDir & "\Razer\RazerAppEngine\User Data\Logs\" & $array[$i]) Next Many thanks Nine!
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