Clear All Event Logs in Event Viewer in Windows  

Page 6 of 11 FirstFirst ... 45678 ... LastLast

  1. Posts : 61,501
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #50

    Barefoot said:
    I was using an older script I beleive I got from Windows Secrets many moons ago. Lately it hasn't been closing the command prompt auotmatically. I wondered why then compared the script here and it had more lines in it. Tried it and it's much slower on the same machine just a few minutes apart. Still not closing automatically. Any ideas why?

    Hello Barefoot,

    The .bat file from Option One should close for you automatically when finished unless you're getting an error message.
    Last edited by Brink; 25 Jul 2018 at 14:19.
      My Computers


  2. Posts : 52
    Windows 10 Pro 64-Bit
       #51

    This is what I'm getting.
    Clear All Event Logs in Event Viewer in Windows-image.png
    As I Said, I've noticed it not closing only in the last few weeks or so. I should have paid attention when, it would probably coincide with an update. Very interesting...
      My Computer


  3. Posts : 61,501
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #52

    Odd. Please try the updated .bat file now in the tutorial to see how it works for you.
    Last edited by Brink; 26 Jul 2018 at 09:04.
      My Computers


  4. Posts : 52
    Windows 10 Pro 64-Bit
       #53

    That closes the command prompt. Just adding "Exit" at the end of the file works.

    Thank you. A very small thing, but it was curious that the command prompt has been closing for years and only recently has it been staying open. I've never looked at the script until comparing it to yours.

    Curious, without "Exit" it closes on your machine?
      My Computer


  5. Posts : 61,501
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #54

    Yeah, it has always automatically closed without needing "Exit" for me. I'm glad it was able to sort it for you.
      My Computers


  6. Posts : 1
    Windows 10 Pro
       #55

    Thank you for your handy batch file ! ..
      My Computer


  7. Posts : 61,501
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #56

    I'm glad it could help devguru, and welcome to Ten Forums.
      My Computers


  8. Posts : 2,422
    Windows 10 Pro x64
       #57

    @Brink
    Hi Shawn,

    I was playing around, in PowerShell, with the event logs and I noticed that in Option 3 the first PowerShell command is the "old" (pre-Vista) one, which although successfully clears the events, it does it only for the Windows "classic" Event logs.

    May I suggest a change in the tutorial to the "new" Get-WinEvent command?

    As you can see from the screenshot below, the difference in the number of Event logs from each command is quite significant.
    Clear All Event Logs in Event Viewer in Windows-eventlogs.png

    If we use the Get-WinEvent command, we cannot use the Clear-Eventlog, as it doesn't work, according to the Microsoft Clear-EventLog doc.

    The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later versions of Windows, use the Get-WinEvent cmdlet.
    In that case we need to go to the .NET EventLogSession Class to clear the event logs.

    If you believe that it's worth changing to the new PS command, the 1st command should be:

    Code:
    Get-WinEvent -ListLog * | ForEach { [System.Diagnostics.Eventing.Reader.EventLogSession]::GlobalSession.ClearLog("$_.LogName") }
    As always, you can test and evaluate it....and act accordingly!!!
      My Computer


  9. Posts : 61,501
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #58

    Hello Dimitri,

    I tested your command, but all I got was red error messages in the elevated PowerShell, and Event Viewer did how anything cleared in "Windows Logs". Am I doing something wrong?

    Using the first command in Option 3 did clear the "Windows Logs" like below.

    Clear All Event Logs in Event Viewer in Windows-event_viewer.jpg
      My Computers


  10. Posts : 2,422
    Windows 10 Pro x64
       #59

    Oops....why?
    Sorry for the trouble Shawn, back to the drawing board. I'll be back!
      My Computer


 

Tutorial Categories

Clear All Event Logs in Event Viewer in Windows Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:57.
Find Us




Windows 10 Forums