#40041 - 2003-05-12 05:41 PM
Using kix to nuke Windows 2000 temp files
|
search66
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
|
|
|
|
#40043 - 2003-05-12 05:49 PM
Re: Using kix to nuke Windows 2000 temp files
|
search66
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
|
|
|
|
#40045 - 2003-05-12 06:23 PM
Re: Using kix to nuke Windows 2000 temp files
|
search66
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
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.
|
|
Top
|
|
|
|
#40049 - 2003-05-12 07:32 PM
Re: Using kix to nuke Windows 2000 temp files
|
search66
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
|
|
|
|
#40051 - 2003-05-12 07:46 PM
Re: Using kix to nuke Windows 2000 temp files
|
search66
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
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
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 ]
|
|
Top
|
|
|
|
#40054 - 2003-05-12 09:49 PM
Re: Using kix to nuke Windows 2000 temp files
|
search66
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
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 %.
|
|
Top
|
|
|
|
#40056 - 2003-05-12 09:58 PM
Re: Using kix to nuke Windows 2000 temp files
|
search66
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
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.
|
|
Top
|
|
|
|
#40058 - 2003-05-12 10:07 PM
Re: Using kix to nuke Windows 2000 temp files
|
search66
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
|
|
|
|
#40060 - 2003-05-12 10:17 PM
Re: Using kix to nuke Windows 2000 temp files
|
search66
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1050 anonymous users online.
|
|
|