Page 1 of 2 12>
Topic Options
#40041 - 2003-05-12 05:41 PM Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
I've seen a variety of scripts that delete cache and temp files; but I've yet to see anything that deletes Windows 2000 user files.

I'd like to have a script that deletes all temp files with each specific workstation. Since each profile uses a different location (ie: c:\documents and settings\USERNAME\local settings\temp), I don't know the syntax of how to point kixtart to that directory.

Anyone have any suggestions?
_________________________
God bless Opera. God bless netjak.

Top
#40042 - 2003-05-12 05:45 PM Re: Using kix to nuke Windows 2000 temp files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please see the UDF Forum under CleanDirectory() - Cleans up the temporary directories (or any arbitrary directory)
_________________________
There are two types of vessels, submarines and targets.

Top
#40043 - 2003-05-12 05:49 PM Re: Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
Nice script, but does that target the individual users temp directories? And how would I specify multiple directories?
_________________________
God bless Opera. God bless netjak.

Top
#40044 - 2003-05-12 06:04 PM Re: Using kix to nuke Windows 2000 temp files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
  Dim $tempfolders[2]

$fileage=31
$filter='*.*'

$tempfolders[0]=expandenvironmentvars('%%TEMP%%')
$tempfolders[1]=expandenvironmentvars('%%WINDIR%%')+'\temp'
if $tempfolders[0]<>'c:\temp'
$tempfolders[2]='c:\temp'
endif

$rc=cleandirectory($tempfolders,$filter,$fileage)

_________________________
There are two types of vessels, submarines and targets.

Top
#40045 - 2003-05-12 06:23 PM Re: Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
Right. Well, I'm not sure what I'm doing wrong but none of my files are being removed (even after changing the date).

But, even with the two posts (which I appreciate) I don't think it will cover the directory I'm fishing for. I need to know what the syntax is for each profiles temp directory.

IE:

c:\documents and settings\smithj\local settings\temp

or

c:\documents and settings\jonesf\local settings\temp

Since each user will have different temp locations, that's what I really need.
_________________________
God bless Opera. God bless netjak.

Top
#40046 - 2003-05-12 07:15 PM Re: Using kix to nuke Windows 2000 temp files
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Are you trying to target a single users directory at logon via script or are you trying to write a script that you as an Admin can reach out and clean up ALL user profiles at once?

Each users profile directory has security applied to it.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#40047 - 2003-05-12 07:22 PM Re: Using kix to nuke Windows 2000 temp files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The following should both point to the same directory under Windows 2000:
code:
%TEMP%
%USERPROFILE%\Local Settings\Temp

_________________________
There are two types of vessels, submarines and targets.

Top
#40048 - 2003-05-12 07:25 PM Re: Using kix to nuke Windows 2000 temp files
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
How will this be done? During logon or as an Admin script?

Normally other users don't have access to other users folders on 2000

You could ENUM this key in the Registry, but I'd omit in code the ones that are not valid user accounts, or at least do an INSTR and look for the "Documents and Settings" to be there.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
ProfileImagePath

Top
#40049 - 2003-05-12 07:32 PM Re: Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
This will be done as a logon script. I want it so whatever user logs in, it will delete the temp files.

I still can't get the one script first post to delete anything.. huhm.
_________________________
God bless Opera. God bless netjak.

Top
#40050 - 2003-05-12 07:42 PM Re: Using kix to nuke Windows 2000 temp files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
shell 'rd /s /q %TEMP%'

for a really quick and dirty way. However, users tend to store things in the TEMP directory so you might delete important stuff, too.

[ 12. May 2003, 20:23: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#40051 - 2003-05-12 07:46 PM Re: Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
Again.. yea that IS a cut-n-dry way to nuke your c:\temp directory.

BUT, it still doesn't solve the problem for the directory I want. I wanted to use the following script below, but the syntax is wrong. Maybe someone can debug my stupidness.

; delete temp files
$directory = "C:\docume~1\%USERPROFILE%\locals~1\Temp"
shell "%comspec% /c DEL C:\temp\*.* /S /Q"
shell "%comspec% /c DEL C:\winnt\temp\*.* /S /Q"
shell "%comspec% /c DEL C:\winnt\*.tmp /S /Q"
shell '%comspec% /c DEL /s /q "$directory"'

***
I guess it doesn't like the "userprofile" thing, but I don't know how to get kix to recognize it.

[ 12. May 2003, 20:04: Message edited by: search66 ]
_________________________
God bless Opera. God bless netjak.

Top
#40052 - 2003-05-12 09:06 PM Re: Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
Through trial and error here is the solution that I came up with and it works:

***
; delete temp files
$tempz = "%USERPROFILE%\locals~1\Temp"
shell "%comspec% /c DEL C:\temp\*.* /Q"
shell "%comspec% /c DEL C:\winnt\temp\*.* /Q"
shell "%comspec% /c DEL C:\winnt\*.tmp /Q"
shell '%comspec% /c DEL "$tempz" /Q'
***

With that said and done... does anyone know a way to specify a time range? So, if I only want to delete files/directories that are 2 days old or older?

Thanks!
_________________________
God bless Opera. God bless netjak.

Top
#40053 - 2003-05-12 09:36 PM Re: Using kix to nuke Windows 2000 temp files
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
How about deleting the oldest to the newest?
code:
for /F %%i in ('dir c:\data\*.* /o:d /b /s') do echo del c:\data\%%i

Take out the 'echo' after the 'do' to delete. You will have to add the proper path data.

[ 12. May 2003, 21:38: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#40054 - 2003-05-12 09:49 PM Re: Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
Huhm... I get an "expected variable" with that line 'a code. Wouldn't there be a way to specify a date range with that?
_________________________
God bless Opera. God bless netjak.

Top
#40055 - 2003-05-12 09:52 PM Re: Using kix to nuke Windows 2000 temp files
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The double % signs are used when executed as part of a CMD file. If you execute this at the command line then only use single %.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#40056 - 2003-05-12 09:58 PM Re: Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
Right. I keep getting an "expected variable or 'EACH'!" error...

Cripes. How about this anyone. How could I use the @DATE command in tangent?

I know that if I use this:

now=@date

(it will show 2003/05/12)

But could I have a:

old=@date (minus a day)

I can easily compare file dates and nuke them based on that. But, I don't know if it is possible to do an: "@DATE minus losing a day"

Anyone have a syntax for that?
_________________________
God bless Opera. God bless netjak.

Top
#40057 - 2003-05-12 10:03 PM Re: Using kix to nuke Windows 2000 temp files
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The above code is NOT KiXtart code. It is batch language for NT OS or better.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#40058 - 2003-05-12 10:07 PM Re: Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
Ok thanks.

No matter what the code, I'd still like to know if there is any syntax with the "@DATE" that could be used to find the previous day.
_________________________
God bless Opera. God bless netjak.

Top
#40059 - 2003-05-12 10:09 PM Re: Using kix to nuke Windows 2000 temp files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Why don't you start by searching the board? Date math routines have been posted in the UDF Forum. Also, if you would have taken a look at the UDF I pointed you to, that one does what you're looking for.
_________________________
There are two types of vessels, submarines and targets.

Top
#40060 - 2003-05-12 10:17 PM Re: Using kix to nuke Windows 2000 temp files
search66 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 25
Loc: Baltimore, MD USA
I appreciate the link, but I'm a noob to kixtart and couldn't make heads or tails from your code. When I tried to do a dry run with it, it didn't work.

I like to understand what I'm doing without blindly copying and pasted. I'll check into the math routines.
_________________________
God bless Opera. God bless netjak.

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 857 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.072 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org