Zombie Posted December 22, 2018 Posted December 22, 2018 Hi, i found this script for restore deleted files from recycle bin...is there a way to add this function to another? I want my program before starting, restore the last file deleted and then start.. I think it can also work simply by closing this func after the execution .. can anyone help me? ty expandcollapse popup#Include <Array.au3> Func _EnumRecycleBinItems($sRoot = '') Local $oShellApp, $oRecycleBin, $oFolderItems, $oItem $oShellApp = ObjCreate('Shell.Application') $oRecycleBin = $oShellApp.NameSpace(10) If Not IsObj($oRecycleBin) Then Return SetError(1, 0, 0) EndIf Local $Ret, $Result[101][6] = [[0]] $sRoot = StringStripWS($sRoot, 3) If $sRoot > '' Then If StringInStr($sRoot, ':') Then $sRoot = StringRegExpReplace($sRoot, ':.*', '') Else $sRoot = '' EndIf If Not FileExists($sRoot & ':') Then Return SetError(1, 0, 0) EndIf EndIf $Ret = DllCall('shell32.dll', 'none', 'SHGetSettings', 'uint*', 0, 'dword', 2) If @error Then Return SetError(1, 0, 0) EndIf $oFolderItems = $oRecycleBin.Items() For $oItem In $oFolderItems If ($sRoot > '') And ($sRoot <> StringLeft($oItem.Path, 1)) Then ContinueLoop EndIf $Result[0][0] += 1 If $Result[0][0] > UBound($Result) - 1 Then ReDim $Result[$Result[0][0] + 100][UBound($Result, 2)] EndIf $Result[$Result[0][0]][0] = $oRecycleBin.GetDetailsOf($oItem, 0) ; Original name $Result[$Result[0][0]][1] = $oRecycleBin.GetDetailsOf($oItem, 1) ; Original path $Result[$Result[0][0]][2] = $oRecycleBin.GetDetailsOf($oItem, 2) ; Deleted date ; $Result[$Result[0][0]][3] = $oRecycleBin.GetDetailsOf($oItem, 3) ; Size $Result[$Result[0][0]][3] = $oItem.Size ; Size $Result[$Result[0][0]][4] = FileGetAttrib($oItem.Path) ; Attributes $Result[$Result[0][0]][5] = $oItem.Path ; Recycle name If (Not $Ret[1]) And (Not StringInStr($Result[$Result[0][0]][4], 'D')) Then If StringInStr($Result[$Result[0][0]][5], '.') Then $Result[$Result[0][0]][0] &= StringRegExpReplace($Result[$Result[0][0]][5], '^.*\.', '.') EndIf EndIf Next ReDim $Result[$Result[0][0] + 1][UBound($Result, 2)] Return $Result EndFunc ;==>_EnumRecycleBinItems $Data = _EnumRecycleBinItems() _ArrayDisplay($Data) ; To recover a file all you need do is: FileMove($Data[1][5], $Data[1][0]) ; Recovers the first file in the list
Nine Posted December 22, 2018 Posted December 22, 2018 (edited) Just check for the most recent deleted file. In other words, test the date of each file, and restore the file that has the highest date. Edited December 22, 2018 by Nine “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
AutoBert Posted December 23, 2018 Posted December 23, 2018 (edited) To recover last deleted file all you need do is: _ArraySort($Data, 1, 1, 0, 2) _ArrayDisplay($Data) if $Data[0][0] > 0 Then FileMove($Data[1][5], $Data[1][0]) ; Recovers last deleted file (1. in sorted list) Edited December 23, 2018 by AutoBert
Zombie Posted December 23, 2018 Author Posted December 23, 2018 Thank you! Is there a way to "hide" the whole list and simply start my program without showing anything?I just want that my program after the start automatically restore the last (or all) deleted file and then do his other job. Can i modify it in any way? ty for reply!
AutoBert Posted December 29, 2018 Posted December 29, 2018 On 23.12.2018 at 5:44 PM, Zombie said: Is there a way to "hide" the whole list and simply start my program without showing anything? Yes, delete line #2 of the code snippet.
Earthshine Posted December 29, 2018 Posted December 29, 2018 (edited) Comment out the arraydisplay line. Edited December 29, 2018 by Earthshine My resources are limited. You must ask the right questions
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