Results 1 to 2 of 2

Thread: Batch File Help

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Batch File Help

    So i got this batch file that removes logs from the event viewer. Here's the code right here:

    @echo off
    FOR /F "tokens=1,2*" %%V IN ('bcdedit') DO SET adminTest=%%V
    IF (%adminTest%)==(Access) goto noAdmin
    for /F "tokens=*" %%G in ('wevtutil.exe el') DO (call :do_clear "%%G")
    echo.
    echo goto theEnd
    :do_clear
    echo clearing %1
    wevtutil.exe cl %1
    goto :eof
    :noAdmin
    exit

    P.S. You need to run it as administrator to get it to work.

    But I don't know how to make it only delete logs from a timed interval. Specifically speaking from 12am to 9am. I've searched up a lot of date and time info on batches but it didnt help much. I'm used to C and Java and all I really need is kind of an if-statement that clears the log if its between that interval. I'm so confused!
    Thank You
    Btw I have Windows 7 if that helps at all

  2. #2
    Join Date
    Dec 2007
    Posts
    2,291

    Re: Batch File Help

    You can test the below batch file code and see if it works for you or not:

    Code:
    forfiles -p "C:\what\ever" -s -m *.* -d <number of days> -c "cmd /c del @path"

Similar Threads

  1. make file name list in excel using batch file
    By shibinpanayi in forum Windows Software
    Replies: 1
    Last Post: 04-06-2011, 03:44 AM
  2. Windows Batch file to output directory names and size to txt file
    By m2thearkus in forum Software Development
    Replies: 6
    Last Post: 16-07-2010, 12:04 AM
  3. How can I play a sound file from a Windows batch file?
    By Linoo in forum Operating Systems
    Replies: 4
    Last Post: 27-03-2010, 07:20 PM
  4. Dos batch file to sort files based on file names.
    By Jon Osborn in forum Windows Server Help
    Replies: 9
    Last Post: 17-06-2009, 11:06 AM
  5. Replies: 3
    Last Post: 12-03-2009, 12:56 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,678,139.55906 seconds with 17 queries