This shows you the differences between two versions of the page.
userspace:cleanup [2013/05/07 15:51] phimeca created |
userspace:cleanup [2021/08/23 08:37] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | This script empty every trash of the system, remove old account listed by AccountsToDelete variable and delete main temp files of every users. | ||
- | |||
- | Be careful! This script is quite straightforward and is not still fully tested. | ||
- | |||
- | Put autoit3.exe and autoit3 Include\ dir in the same dir as once.ins. | ||
- | |||
- | once.ins: | ||
- | < | ||
- | [Actions] | ||
- | |||
- | DefVar $ProductId$ | ||
- | DefVar $INST_NTVersion$ | ||
- | DefVar $TmpSuffix$ | ||
- | DefVar $AccountsToDelete$ | ||
- | |||
- | Set $ProductId$ = " | ||
- | |||
- | ; list of accounts to delete separated by a ' | ||
- | Set $AccountsToDelete$ = " | ||
- | |||
- | Set $INST_NTVersion$ = GetMsVersionInfo | ||
- | |||
- | ShowBitmap " | ||
- | |||
- | if ($INST_NTVersion$ >= " | ||
- | Set $TmpSuffix$ = " | ||
- | else | ||
- | Set $TmpSuffix$ = "Local Settings\Temp" | ||
- | endif | ||
- | |||
- | |||
- | Message " | ||
- | ExecWith_account " | ||
- | |||
- | Message "Purge Trash bins. Please wait a while." | ||
- | DOsInAnIcon_trash | ||
- | |||
- | Message " | ||
- | ExecWith_temp " | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | [DOsInAnIcon_trash] | ||
- | rd /S /Q %SystemDrive%\$Recycle.Bin | ||
- | |||
- | |||
- | |||
- | [ExecWith_account] | ||
- | #include < | ||
- | |||
- | Local $AccountsToDelete = StringSplit(" | ||
- | Local $AccountDir = " | ||
- | |||
- | $DirList = _FileListToArray($AccountDir, | ||
- | |||
- | If IsArray($DirList) == 0 Then | ||
- | ;MsgBox(0, "", | ||
- | ConsoleWrite(" | ||
- | Exit | ||
- | EndIf | ||
- | |||
- | For $i = 1 To $DirList[0] | ||
- | Local $CurrentAccount = $DirList[$i] | ||
- | ConsoleWrite(" | ||
- | For $j = 1 To $AccountsToDelete[0] | ||
- | Local $AccountToDelete = $AccountsToDelete[$j] | ||
- | ; | ||
- | If $CurrentAccount == $AccountToDelete Then | ||
- | ConsoleWrite(": | ||
- | DirRemove($AccountDir & " | ||
- | ExitLoop | ||
- | EndIf | ||
- | Next | ||
- | ConsoleWrite(@CRLF) | ||
- | Next | ||
- | |||
- | |||
- | |||
- | [ExecWith_temp] | ||
- | ; remove only content of temp dir | ||
- | #include < | ||
- | |||
- | Local $ProfileDir = " | ||
- | Local $TmpSuffix = " | ||
- | |||
- | Local $DirList = _FileListToArray($ProfileDir, | ||
- | |||
- | If @error = 1 Then | ||
- | ConsoleWrite(" | ||
- | Exit | ||
- | EndIf | ||
- | |||
- | For $i = 1 To $DirList[0] | ||
- | Local $CurrentAccount = $DirList[$i] | ||
- | Local $TmpDir = $ProfileDir & " | ||
- | ConsoleWrite(" | ||
- | |||
- | Local $FileList = _FileListToArray($TmpDir, | ||
- | If IsArray($FileList) == 0 Then | ||
- | ConsoleWrite(" | ||
- | ContinueLoop | ||
- | EndIf | ||
- | ConsoleWrite(" | ||
- | For $j = 1 To $FileList[0] | ||
- | Local $TmpFile = $TmpDir & " | ||
- | ; | ||
- | DirRemove($TmpFile, | ||
- | FileDelete($TmpFile) | ||
- | Next | ||
- | | ||
- | Next | ||
- | </ | ||