Page 1 of 1 1
Topic Options
#140934 - 2005-06-03 12:06 AM DEL * on %TEMP% issue
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
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


Top
#140935 - 2005-06-03 12:15 AM Re: DEL * on %TEMP% issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
just quit?
you say that it crashed/died?
_________________________
!

download KiXnet

Top
#140936 - 2005-06-03 01:01 AM Re: DEL * on %TEMP% issue
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Weird... just ran this on a couple other 2000 Pro systems and it worked fine.

Have no idea at the moment what's happening there.

Will post back again when/if I find out more or run into another system that has the same issue.

Hmmmm... Maybe some sort of Spyware infected it and is somehow interfering with WKIX32

 

Top
#140937 - 2005-07-05 03:01 AM Re: DEL * on %TEMP% issue
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well never did find out what caused the issue. However I did run into another issue where by it could easily delete all files on the system if the var was blank as it would then mean to use the root of the drive and start removing files. This update checks to make sure it will never start from the root.
 
Code:
Function CleanTemp()
Dim $HKLTemp,$HKUTemp
$HKLTemp='%windir%\TEMP\'
If InGroup(@WKSTA+'\'+SidToName('S-1-5-32-544'))
If Not EmptyFolder($HKLTemp)
If Len($HKLTemp)>10
DEL $HKLTemp+'*' /C /F /H /S
EndIf
EndIf
EndIf
$HKUTemp='%temp%\'
If Not EmptyFolder($HKUTemp)
If Len($HKUTemp)>15
DEL $HKUTemp+'*' /C /F /H /S
EndIf
EndIf
EndFunction
 


Function EmptyFolder($_)
Dim $
$=Dir($_)
Do $=Dir() Until $<>"." And $<>".." Or @ERROR
If $="." Or $=".." Or Not Len($) $emptyfolder=1 EndIf
EndFunction


Top
#140938 - 2005-09-02 10:52 PM Re: DEL * on %TEMP% issue
iffy Offline
Starting to like KiXtart

Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
Had that happen to me just last weekend while updating some scripts because of a migration (Exchange 2003). Luckily I only killed 2 VMware boxes and 1 actual workstation. And the workstation got a scripted installation but still, freaked my that this "bug" could have hit monday morning...

Btw.. I once typed rm ./ -r or something simular while logged as root on an aix 4.3 production machine.. some typo saved my ass

Top
#140939 - 2005-09-04 01:34 AM Re: DEL * on %TEMP% issue
Skatterbrainz Offline
Starting to like KiXtart

Registered: 2002-10-17
Posts: 172
Loc: Virginia, USA
(NTDOC) Forgive me if this is a stupid question, but just out of curiosity, was the user session a local admin or local "user" in all cases? I've had some issues trying to manipulate files under the %userprofile% folder tree on W2K systems (VBscript as well as KixTart), when the user had no local elevated rights.
_________________________
silence is golden, but duct tape is silver

Top
#140940 - 2005-09-04 02:37 AM Re: DEL * on %TEMP% issue
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
that's weird.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 259 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.053 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.