Page 1 of 1 1
Topic Options
#59630 - 2001-10-05 05:30 PM Please help here.
Anonymous
Unregistered


I need to write a script to auto delete
*.tmp *.chk and ~*.* files from users Temp directories. Add to this the fact that some of the older machines on site have their %systemroot% on the "D" drive and then some have the Temp dir as C:\Temp and some have C:\winnt\temp. I need to check all this as well before I delete.

Any help would be appreciated.

Jassen

Top
#59631 - 2001-10-05 05:45 PM Re: Please help here.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
On NT you say ?

you can determine the locations by parsing the %TEMP% and %TMP% environment variables ...

then get the best examples from this
Post and the links behind ...

hth

Jochen

btw. wasn't it MCA who have a neat example of cleaning up temp foldetrs ???
check out http://home.wanadoo.nl/scripting

[ 05 October 2001: Message edited by: jpols ]

_________________________



Top
#59632 - 2001-10-09 12:01 AM Re: Please help here.
Anonymous
Unregistered


Thanx for the advice. Seem to be pointing in the right direction.
Top
#59633 - 2001-10-08 11:19 PM Re: Please help here.
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Jassen,

Based upon the %temp% variable this should work fine. However you could +R attribs or the file could be in use and it would not delete.

code:
DEL "%TEMP%\*.tmp"
DEL "%TEMP%\*.CHK"
DEL "%TEMP%\~*.*"

Very quick simple code. Not bullet proof and not a search and destroy method. Here is another example also.

code:
If @InWin = 1
RUN '%COMSPEC% RD /S /Q %TEMP%'
EndIf
If @InWin = 2
Shell "%COMSPEC% DelTree /Y %TEMP%"
EndIf


Top
#59634 - 2001-10-17 02:10 AM Re: Please help here.
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Jassen, welcome to the board.

For ideas about removing all kind of temporary files from your system
see our script cleanup.kix, which you can find on our site
http://home.wanadoo.nl/scripting

btw: a little reaction and correction on NTDOC scripts

  • the usage of del can let your script hang in some situations, when f.e.
    a file is busy. be aware of that.
    an alternative is the usage of windows 95 command deltree with option /y,
    which can handle such situations.
  • be aware to check your %temp% still exist after the rd or deltree
    operation.
    shell "%comspec% /c deltree /y %temp%" will also remove directory
    %temp%. to prevent it change it to:
    shell "%comspec% /c deltree /y %temp%\."
    Our code will be
    code:

    IF @inwin = 1
    SHELL "%comspec% /c rd /s /q %temp%"
    ELSE
    SHELL "%comspec% /c deltree /y %temp%\."
    ENDIF
    IF (Exist("%temp%\nul") = 0)
    MD %temp%
    ENDIF


    btw: we think NTDOC was forgotten to type /c switch in run and shell
    command.

Greetings.


Symbol on our homepage has been linked to related http://kixtart.org topic.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#59635 - 2001-10-17 10:14 AM Re: Please help here.
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
The comment:

btw: we think NTDOC was forgotten to type /c switch in run and shell
command.

True...
I tried this code from a command prompt not a logon batch call of a KiXtart script. It does work from a command prompt without the /c (I think /c is the default behavior on 2000 anyways).

and I did mention that it is not bullet proof. Did not test, but from past experience, I would say that MCA's code would be more bullet proof then my sample.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2924 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

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

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