Announcement

Collapse
No announcement yet.

script to delete cookie based on date TermServers

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • script to delete cookie based on date TermServers

    Hello, Can someone help me with creating a vbs or or batch file. I am trying to have a script run that deletes cookies that are older then 60 days.

    Since im looking to keep the index.dat file in the cookie dir i just cant delete *.*

    and use a %username% for the users dir.

    thanks allot.

  • #2
    Re: script to delete cookie based on date TermServers

    batch:
    Code:
    @echo off
    SetLocal enableextensions
    
    Forfiles /p "%userprofile%\Cookies" /d -60 /c "cmd.exe /c If /i @isdir==False Del @file /a/f /a-S /s"
    Forfiles.exe comes with 'Windows server 2003' and 'Windows Vista'.
    (There is also an old version from the Windows 2000 resource kit, this one does not work with the syntax above!)
    ForFiles.exe must be present in the Windows\system32 folder.
    (On Windows xp you can use the Windows 2003 version)

    Del command switches:
    Del <file> /a/f /a-S /s
    Deletes all files exept systemfiles (like: index.dat)

    Forfiles command switch: /d -60
    list only files older than 60 day's

    "%userProfile%" results in the local profile path of the current user


    \Rems


    Forfiles tips;
    http://winhlp.com/node/180 <- Win2k and Win2k3 Forfiles
    http://technet2.microsoft.com/window....mspx?mfr=true <- Win2k3 Forfiles
    http://www.jsifaq.com/SF/Tips/Tip.aspx?id=5645 ,- Win2k Forfiles
    http://www.dialogmedical.com/kb/0000...FilesByAge.pdf Win2k3 Forfiles
    Last edited by Rems; 20th February 2008, 17:01. Reason: changed @isdir==TRUE To @isdir==FALSE (!)

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: script to delete cookie based on date TermServers

      For some reason that would not work but thanks for the tip

      Code:
      M:\WINDOWS\system32\Forfiles -p "M:\Documents and Settings\%username%\Cookies"  -m *.txt -d -120 -c "CMD /C del @file"
      seems to do it

      Comment


      • #4
        Re: script to delete cookie based on date TermServers

        There was a typo: If @IsDir should be FALSE !! because you want to list files not directories. Note FALSE must be in uppercase! (or else use IF /i).

        You should try these switches with the Del command:
        Del @file /a/f /a-S

        reviewed batch (adjusted to your static paths);
        Code:
        @"M:\WINDOWS\system32\Forfiles.exe" -p "M:\Documents and Settings\%username%\Cookies"  -m *.txt -d -60 -c "cmd.exe /c If @isdir==FALSE Del @file /a/f /a-S"
        I also corrected the batch in my previous reply.

        \Rems

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment

        Working...
        X