Hallo!
Für den Temp-Ordner ist eigentlich keine besondere Berechtigung nötig.
Allerdings sind einige Dateien dort natürlich immer gesperrt, weil sie von Prozessen verwendet werden! Das Löschen mit
FileRemoveDir
von Ordnern scheitert dann aber gänzlich, wenn nur eine Datei darin gesperrt ist.
Ich hatte mir vor einiger Zeit dazu mal ein einfaches Script erstellt, vielleicht hilft es weiter...

; niO
FileInstall, sad.gif, %A_Temp%\sad.gif, 1
; OK
FileInstall, biggrin.gif, %A_Temp%\biggrin.gif, 1
Gui, Add, Edit, x6 y11 w360 h20 ReadOnly Center vpath, Datei
Gui, Add, Picture, x6 y101 w30 h30 , %A_Temp%\sad.gif
Gui, Add, Picture, x6 y61 w30 h30 , %A_Temp%\biggrin.gif
Gui, Font, s12
Gui, Add, Text, x56 y38 w100 h30 , Dateien
Gui, Add, Text, x+5 y38 w100 h30 , Ordner
Gui, Font,
Gui, Add, edit, x56 y61 w100 +ReadOnly vdel, 0
Gui, Add, edit, x+5 y61 w100 +ReadOnly vdelo, 0
Gui, Add, text, x+5 y61 w100 , gelöscht
Gui, Add, edit, x56 y101 w100 +ReadOnly vsad, 0
Gui, Add, edit, x+5 y101 w100 +ReadOnly vsad2, 0
Gui, Add, text, x+5 yp w100 +ReadOnly, nicht gelöscht
Gui, Add, edit, x18 y+42 w180 +ReadOnly vwkb1, 0
Gui, Add, Button, x6 y+15 w140 h30 +Default gok, &OK
Gui, Add, GroupBox, x6 y140 w200 h45 , frei gewordener Speicher
GuiControl, Hide, ok
Gui, Show, , Tempkiller
wkb = 0
err = 0
erro = 0
count = 0
sad = 5
; --------------------------------nur Dateien----------------------------------------------
Loop, %A_Temp%\*.*, 0, 1
{
GuiControl, , path, %A_LoopFileName%
; Dateien
FileDelete, %A_LoopFileLongPath%
if ErrorLevel <> 0
{
err++
GuiControl, , sad, %err%
Continue
}
count++
GuiControl, , del, %count%
wkb += A_LoopFileSize
GuiControl, , wkb1, % calc_kb(wkb)
Continue
}
; ------------------------------nur Ordner------------------------------------------------
Loop, %A_Temp%\*.*, 2, 1
{
GuiControl, , path, %A_LoopFileName%
FileRemoveDir, %A_LoopFileLongPath%,
if ErrorLevel <> 0
{
erro++
; MsgBox, %A_LoopFileLongPath%
GuiControl, , sad2, %erro%
Continue
}
ordner++
GuiControl, , delo, %ordner%
Continue
}
; ------------------------------------------------------------------------------
GuiControl, , path,
Return
; ------------------------------------------------------------------------------
ok:
GuiClose:
ExitApp
; ------------------------------------------------------------------------------
; ################ Funktion ##################
calc_kb(wievielb, nachkomma = 3) ; Übergabe von Bytes, Nachkommas- Rückgabe dynamisch(bytes,kB,mB,GB)
{
Return (wievielb > 1073741824) ? Round((wievielb / 1073741824), nachkomma) " GB" : ((wievielb > 1048576) ? Round((wievielb / 1048576), nachkomma) " MB" : ((wievielb > 1024) ? Round((wievielb / 1024),nachkomma) " kB" : wievielb . " bytes"))
}