Tag.. Als ich neulich mal so die sysinternals homepage durchstöbert hab fand ich movefile.
Es ist ein winziges Programm, das eine Windowsfunktion nutzt, um Dateien, welche Benutzt werden zu löschen.
Windows löscht die Dateien beim nächsten Hochfahren, bevor irgendeinetwas läuft, dadurch KANN die Datei garnicht benutzt werden, wenn sie gelöscht wird...
Mein Tool ist eine kleine Visualisierung + Auto(it)matiesierung des ganzen.
Es nutzt movefile (welches ein cmdline tool ist) um einen ganzen order rekursiv (alle dateien, auch in Unterordnern) in diese Windows funktion einzutragen.
ACHTUNG! IN MEINER VM HAT'S AUCH BEI SYSTEM32 GEKLAPPT!
IHR KÖNNT EUCH SICHERLICH DENKEN WAS PASSIERT IST!
(Er konnte nicht starten, da er hal.dll nicht gefunden hat)
Hier ist der sourcecode, ich würde movefile.exe ja anhängen, aber da ich meine, man sollte niemals .exe's von jemanden, der irgendjemand sein kann (z.b. ich) downloaden, also ist hier der original-link zu sysinternals...
In FileInstall noch den pfad zu movefile.exe eintragen...
http://technet.microsoft.com/de-de/sysinternals/bb897556.aspx <== Movefile
==>Quelltext
Spoiler anzeigen
#RequireAdmin
If $CMDLINE[0] == 1 Then
$check = _FileListToArray ($CMDLINE[1])
If IsArray ($check) Then
MsgBox (16, "Failure", "Some of the file could'nt be deleted.")
Else
MsgBox (64, "Success", "All files deleted.")
EndIf
FileDelete (@StartupDir & "\deleterCheck.lnk")
Exit
EndIf
FileInstall ("pfad zu movefile.exe", @TempDir & "\movefile.exe")
$delFolder = FileSelectFolder ("Select folder to delete on next Startup!", "")
If @error Then Exit
If $delFolder = @SystemDir Or $delFolder = @WindowsDir Then MsgBox (48, "Warning", "You're attemping to delete the system folder! THIS IS GOING TO WORK! YOUR SYSTEM WON'T REOOT ANYMORE!")
If MsgBox (4, "Confirm", "Please confirm that you want to delete the following folder: " & @CRLF & $delFolder) == 6 Then
$lst = _RecursiveFileListToArray ($delFolder, "", 1)
For $i = 1 To $lst[0]
TrayTip ("Deleter", "Deleting file: " & $i & " of " & $lst[0], 1)
ShellExecute (@TempDir & "\movefile.exe", $lst[$i] & ' ""', "", "", @SW_HIDE)
Next
FileCreateShortcut (@ScriptFullPath, @StartupDir & "\deleterCheck.lnk", "", $delFolder, "This will make deleter check if all files in " & $delFolder & " were deleted succesfully.")
MsgBox (64, "Finished", "Deleter fineshed. All files should be added to the list." & @CRLF & "This program added it's self to the autostart, to make sure that al files were deleted." & @CRLF & "If you're using Vista / 7 you'll have to confirm this Program on next reboot.")
If MsgBox (4, "Restart", "Restart now?") == 6 Then Shutdown (2)
Else
MsgBox (16, "", "Aborted")
EndIf
FUNC OnAutoItExit ()
FileDelete (@TempDir & "\movefile.exe")
ENDFUNC
;===============================================================================
; Function Name: _RecursiveFileListToArray($sPath, $sPattern, $iFlag = 0, $iFormat = 1, $sDelim = @CRLF)
; Description:: gibt Verzeichnisse und/oder Dateien (rekursiv) zurück, die
; einem RegExp-Pattern entsprechen
; Parameter(s): $sPath = Startverzeichnis
; $sPattern = ein beliebiges RexExp-Pattern für die Auswahl
; $iFlag = Auswahl
; 0 = Dateien & Verzeichnisse
; 1 = nur Dateien
; 2 = nur Verzeichnisse
; $iFormat = Rückgabeformat
; 0 = String
; 1 = Array mit [0] = Anzahl
; 2 = Nullbasiertes Array
; $sDelim = Trennzeichen für die String-Rückgabe
; Requirement(s): AutoIt 3.3.0.0
; Return Value(s): Array/String mit den gefundenen Dateien/Verzeichnissen
; Author(s): Oscar (https://autoit.de/www.autoit.de)
; Anregungen von: bernd670 (https://autoit.de/www.autoit.de)
;===============================================================================
Func _RecursiveFileListToArray($sPath, $sPattern, $iFlag = 0, $iFormat = 1, $sDelim = @CRLF)
Local $hSearch, $sFile, $sReturn = ''
If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
$hSearch = FileFindFirstFile($sPath & '*.*')
If @error Or $hSearch = -1 Then Return SetError(1, 0, $sReturn)
While True
$sFile = FileFindNextFile($hSearch)
If @error Then ExitLoop
If StringInStr(FileGetAttrib($sPath & $sFile), 'D') Then
If StringRegExp($sPath & $sFile, $sPattern) And ($iFlag = 0 Or $iFlag = 2) Then $sReturn &= $sPath & $sFile & '\' & $sDelim
$sReturn &= _RecursiveFileListToArray($sPath & $sFile & '\', $sPattern, $iFlag, 0)
ContinueLoop
EndIf
If StringRegExp($sFile, $sPattern) And ($iFlag = 0 Or $iFlag = 1) Then $sReturn &= $sPath & $sFile & $sDelim
WEnd
FileClose($hSearch)
If $iFormat Then Return StringSplit(StringTrimRight($sReturn, StringLen($sDelim)), $sDelim, $iFormat)
Return $sReturn
EndFunc
Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0)
Local $hSearch, $sFile, $sFileList, $sDelim = "|"
$sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash
If Not FileExists($sPath) Then Return SetError(1, 1, "")
If StringRegExp($sFilter, "[\\/:><\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "")
If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
$hSearch = FileFindFirstFile($sPath & $sFilter)
If @error Then Return SetError(4, 4, "")
While 1
$sFile = FileFindNextFile($hSearch)
If @error Then ExitLoop
If ($iFlag + @extended = 2) Then ContinueLoop
$sFileList &= $sDelim & $sFile
WEnd
FileClose($hSearch)
If Not $sFileList Then Return SetError(4, 4, "")
Return StringSplit(StringTrimLeft($sFileList, 1), "|")
EndFunc;==>_FileListToArray
; Note ..........: Special Thanks to Helge and Layer for help with the $iFlag update speed optimization by code65536, pdaughe
; Author ........: SolidSnake <MetalGX91 at GMail dot com>
Viel spaß damit (Vorallem denen, die ne VM haben, die weg kann :D), Das Schwert.
P.S.: Zu na auswahl jeder einzelnen Datei war ich jetzt zu faul, könnt ihr ja selber bauen