I'm not sure what is causing this because I'm unable to duplicate the issue on my system.
The following code will delete ALL the files in the main TEMP folder - like C:\WINDOWS\TEMP or C:\WINNT\TEMP
It also deletes all the files in %TEMP% for the user on XP, but when I went to test it on 2000 Pro w/SP4 it did not remove all the files, in fact it seemed to just quit and not even show the debug error line.
Have tested on both KiX 4.23 and 4.5 RC1 seems to work fine on my XP system, but not correctly on 2000 Pro.
Code:
Function CleanTemp()
Dim $HKLTemp,$HKLTmp,$HKUTemp,$HKUTmp,$Now
$HKLTemp=ExpandEnvironmentVars(ReadValue('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment','TEMP'))
$HKLTmp=ExpandEnvironmentVars(ReadValue('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment','TMP'))
$HKUTemp=ExpandEnvironmentVars(ReadValue('HKCU\Environment','TEMP'))
$HKUTmp=ExpandEnvironmentVars(ReadValue('HKCU\Environment','TMP'))
If Not EmptyFolder($HKLTemp)
If Exist($HKLTemp+'\*')
DEL $HKLTemp+'\*' /C /F /H /S
? 'ERROR: ' + @ERROR ; This line does show on console and files are deleted
EndIf
EndIf
If Not EmptyFolder($HKUTemp)
If Exist($HKUTemp)
DEL $HKUTemp+'\*' /C /F /H /S
? 'ERROR: ' + @ERROR ; This line is not shown on console and files not deleted
; SHELL '%COMSPEC% /E:1024 /C RD /S /Q ' + '"'+$HKUTemp+'"' + ' >nul 2>nul'
; The SHELL line to remove the folder works just fine.
EndIf
EndIf
EndFunction
Function EmptyFolder($_)
Dim $
$=Dir($_)
Do $=Dir() Until $<>"." And $<>".." Or @ERROR
If $="." Or $=".." Or Not Len($) $emptyfolder=1 EndIf
EndFunction