How to replace win log files

Discussion in 'Scripting' started by ma.prezentalok, May 5, 2019.

  1. ma.prezentalok

    ma.prezentalok MDL Novice

    Oct 22, 2012
    30
    1
    0
    #1 ma.prezentalok, May 5, 2019
    Last edited: May 5, 2019
    Hi could someone help me out to move these files?

    I'm trying to execute the following:

    for /f %x in ('wevtutil el') do wevtutil sl "%x" /lfn:"D:\Logs\%x.evtx"

    But x in cases sometimes returns with a folder such as "microsoft-windows-wordpad/diagnostic". That means

    wevtutil sl "microsoft-windows-wordpad/diagnostic" /lfn:"D:\Logs\microsoft-windows-wordpad/diagnostic.evtx" that is bad. Can someone rewrite this so forward slash is replaced with a backslash in the do block and a subdirectory is created when necessary? (win only starts to log if the folder exists as in the path)
     
  2. Thomas Dubreuil

    Thomas Dubreuil MDL Member

    Aug 29, 2017
    212
    325
    10
    basics...

    set "torename=wevtutil sl "microsoft-windows-wordpad/diagnostic" /lfn:"D:\Logs\microsoft-windows-wordpad/diagnostic.evtx""
    set "torename=%torename:/=\%"
    set "torename=%torename:\lfn=/lfn%"

    etc.

    echo %torename%
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...