1. #1

    Auto-archive logs/WTF/etc Batch Script

    So, for a few years now, before Windows 10, I've had Windows set up to run a Batch script every time WoW exits that copies and archives my chat and combat logs along with my screenshots. It has evolved over time to include taint logs, Fonts folder, Sound folder, and the last 9 iterations of my entire WTF folder. I never thought of sharing this, even though I believe I've mentioned it before, but user ComputerNerd in a recent logging thread has shown interest. It may be helpful for those willing to mess with the Task Manager, creating an .xml file and a .bat file, and possibly editing Windows local security policy (harmless, but I don't think it's required anymore, or actually required in the past, since my auditing has been off since I updated to 10 and everything still works).

    Basically, this process will archive Fonts, Screenshots, Sound, WTF, WoWCombatLog.txt, WoWChatLog.txt, taint.log, and self-preserve the wowmaint.bat you make below. This completely saves your WoW install if anything should happen to it, minus the actual game install itself. An example of an application of this, you would freshly login for a raid night with logging on, raid, then immediately exit the game upon completion of the raid night, and that combat log will be numbered and archived. The default numbers for all three logs are 999, so if you were to start and exit WoW once every day, that's 999 days of saved logs.

    One more note, the file dates will be wonky due to a default "file tunneling" option in Windows. It took me several regedit tampers and other things I don't remember to get Windows to stop that, so I don't think I can accurately describe that. Your logs may end up keeping the creation and modified times of the first files this code sees and randomly update over time, so batches of files will share different times. The file numbers count up, WoWChatLog1.txt is the oldest file and the first to be deleted once WoWChatLog999.txt is reached, so at least you can sort with that.

    First, open any text editor and paste the following:

    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    <RegistrationInfo>
    <Date>2004-11-23T12:34:56</Date>
    <Author>Kanegasi</Author>
    <Description>Runs the wowmaint.bat file when a World of Warcraft client terminates.</Description>
    <URI>\wowmaint</URI>
    </RegistrationInfo>
    <Triggers>
    <EventTrigger>
    <Enabled>true</Enabled>
    <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Security"&gt;&lt;Select Path="Security"&gt;*[System[(EventID=4689)]] and *[EventData[Data[@Name="ProcessName"] and (Data="C:\Program Files\World of Warcraft\Wow.exe")]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    <Delay>PT5S</Delay>
    </EventTrigger>
    </Triggers>
    <Principals>
    <Principal id="Author">
    <UserId>S-1-5-18</UserId>
    <RunLevel>HighestAvailable</RunLevel>
    </Principal>
    </Principals>
    <Settings>
    <MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
    <StopOnIdleEnd>false</StopOnIdleEnd>
    <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
    </Settings>
    <Actions Context="Author">
    <Exec>
    <Command>"C:\Program Files\World of Warcraft\wowmaint.bat"</Command>
    </Exec>
    </Actions>
    </Task>



    There are TWO file paths in the above blob of text. Make sure they point to your World of Warcraft folder.

    Now save the file as wowmaint.xml anywhere (using something like "all files" in Notepad or whatever your text editor has to enable saving the file type). It can be deleted or moved after you're done here.

    For those familiar with the task scheduler and Windows user IDs, I have found that the local system is required, or there will be problems with cd'ing to another drive. The script also edits the Logs folder in the WoW install, which is in Program Files, protected by default in Windows 10.

    Next, another new file with the following:

    set $doc=S:\Documents
    set $pic=S:\Pictures
    setlocal enableDelayedExpansion
    tasklist | findstr /i /c:"wow.exe" /c:"wow-64.exe"
    if %errorlevel% equ 0 exit
    cd /d "%~dp0Logs"
    if not exist WoWChatLog.txt goto combat
    for %%S in (WoWChatLog.txt) do if %%~zS equ 0 type nul > WoWChatLog.txt & del /f /q WoWChatLog.txt & goto combat
    for /f %%C in ('dir /b WoWChatLog*.txt ^| find /c /v ""') do set $num=%%C
    if %$num% geq 1000 type nul > WoWChatLog1.txt & del /f /q WoWChatLog1.txt
    set $count=0
    for /f "tokens=*" %%T in ('dir /b /o:d WoWChatLog*.txt') do (
    set /a $count+=1
    ren %%T WoWChatLog!$count!.txt)
    :combat
    if not exist WoWCombatLog.txt goto taint
    for %%S in (WoWCombatLog.txt) do if %%~zS equ 0 type nul > WoWCombatLog.txt & del /f /q WoWCombatLog.txt & goto taint
    for /f %%C in ('dir /b WoWCombatLog*.txt ^| find /c /v ""') do set $num=%%C
    if %$num% geq 1000 type nul > WoWCombatLog1.txt & del /f /q WoWCombatLog1.txt
    set $count=0
    for /f "tokens=*" %%T in ('dir /b /o:d WoWCombatLog*.txt') do (
    set /a $count+=1
    ren %%T WoWCombatLog!$count!.txt)
    :taint
    if not exist taint.log goto files
    for %%S in (taint.log) do if %%~zS equ 0 type nul > taint.log & del /f /q taint.log & goto files
    for /f %%C in ('dir /b taint*.log ^| find /c /v ""') do set $num=%%C
    if %$num% geq 1000 type nul > taint1.log & del /f /q taint1.log
    set $count=0
    for /f "tokens=*" %%T in ('dir /b /o:d taint*.log') do (
    set /a $count+=1
    ren %%T taint!$count!.log)
    :files
    robocopy "%~dp0." "%$doc%\WoW other" *.bat
    robocopy "%~dp0Fonts" "%$doc%\WoW other\Fonts" /E
    robocopy "%~dp0Logs" "%$doc%\WoW logs" WoW*Log*.txt
    robocopy "%~dp0Logs" "%$doc%\WoW logs" taint*.log
    robocopy "%~dp0Screenshots" "%$pic%\WoW screenshots"
    robocopy "%~dp0Sound" "%$doc%\WoW other\Sound" /E
    robocopy "%$doc%\WoW logs" "%~dp0Logs" WoW*Log*.txt
    robocopy "%$doc%\WoW logs" "%~dp0Logs" taint*.log
    robocopy "%$doc%\WoW other" "%~dp0." *.bat
    robocopy "%$doc%\WoW other\Fonts" "%~dp0Fonts" /E
    robocopy "%$doc%\WoW other\Sound" "%~dp0Sound" /E
    robocopy "%$pic%\WoW screenshots" "%~dp0Screenshots"
    cd /d "%$doc%\WoW WTF"
    md WTF
    for /f %%C in ('dir /b WTF* ^| find /c /v ""') do set $num=%%C
    if %$num% geq 10 rd /s /q WTF1
    set $count=0
    for /f "tokens=*" %%T in ('dir /b /o:d WTF*') do (
    set /a $count+=1
    ren %%T WTF!$count!)
    robocopy "%~dp0WTF" "%$doc%\WoW WTF\WTF%$count%" /E



    There are two paths at the top of this file for you to edit. Do not edit anything else.

    The first one is a folder to save the three generated folders (WoW logs, WoW other, and WoW WTF), the second one is where to save your screenshots. To get the most out of this, I suggest setting up the target locations to a drive separate from the one your WoW is installed on. Save this file as wowmaint.bat and put it in your main WoW folder.

    Now that we have the two files, open your Task Scheduler by opening your start menu and just typing task scheduler. The Windows 10 auto search should pop up a link to scheduler before you're finished typing. For Windows 7 and under, hold your Windows key and hit the R key, then type Taskschd.msc and click Run.

    In the Task Scheduler window, with "Task Scheduler Library" highlighted on the left, click "Import Task..." on the right, find the wowmaint.xml file you made, then click OK.

    You're done! I left out touching the local security policy hoping that this will work for everyone, but if it doesn't, I'll have to explain that one. Let me know. To test, just start WoW and log in, then exit. Five seconds after the client is completely gone, your World of Warcraft\Logs folder will get the new name1 logs if you're recording them and your two target folders will get the three generated folders and screenshots.

    Edit: I almost forgot about this thread. If this isn't working for you, and you double-checked all the file/folder paths, then you may have to edit the Local Security Policy.

    Open the Local Security Policy by typing that into the start menu for Windows 10, or going to Start > Programs > Administrative Tools for other Windows, and checking this box: https://i.imgur.com/EyqlaMM.png
    Last edited by Kanegasi; 2019-11-18 at 01:14 AM. Reason: Remove Wow-64, long lines in code boxes causes right side of post to cut off
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  2. #2
    Thank you.
    Bookmarked to have a more thorough look when I can.
    Used to do very minor stuff with batch files back in the day, but got out of the habit.
    Very useful tools still, even with modern replacements such as PowerShell.

    Very nice with the addition of a scheduled task, particularly useful for the automation side.
    Quote Originally Posted by DeadmanWalking View Post
    Your forgot to include the part where we blame casuals for everything because blizzard is catering to casuals when casuals got jack squat for new content the entire expansion, like new dungeons and scenarios.
    Quote Originally Posted by Reinaerd View Post
    T'is good to see there are still people valiantly putting the "Ass" in assumption.

  3. #3
    Good stuff.

    I coded my own tiny little C# thing to copy logs and set that to auto-run once a week a while ago, precisely because I wanted something like this.

  4. #4
    Deleted
    hello

    it doesn't work for me : i have nothing in documents neither in pictures
    but in my logs directory it seems to archive a wowcombatlog1.txt and i have a WTF1 folder appearing in my logs directory : is that normal ?

    maybe it has something to do with my wow folder being in G and not C, . do i have to edit more things due to the directory ?
    Last edited by mmoc05dde699e7; 2017-05-11 at 06:18 AM.

  5. #5
    99% ppl need not this wall of text nobody even understand how it's working but only 1 line in bat file like
    "c:\program files\winrar\rar.exe" a -r -m5 "G:\wtfbackups\wtf%date%.rar" "d:\games\World of Warcraft\WTF"

  6. #6
    Quote Originally Posted by Miino View Post
    hello

    it doesn't work for me : i have nothing in documents neither in pictures
    but in my logs directory it seems to archive a wowcombatlog1.txt and i have a WTF1 folder appearing in my logs directory : is that normal ?

    maybe it has something to do with my wow folder being in G and not C, . do i have to edit more things due to the directory ?
    That sounds about right. You need to edit the three paths in the first file and the two lines at the top of the second file.


    Quote Originally Posted by ztn View Post
    99% ppl need not this wall of text nobody even understand how it's working but only 1 line in bat file like
    "c:\program files\winrar\rar.exe" a -r -m5 "G:\wtfbackups\wtf%date%.rar" "d:\games\World of Warcraft\WTF"
    When I get a chance later today, I'll do a line-by-line explanation of the second code, which is the batch script. The first code is simply what you get when you export a task from the task scheduler.



    Edit: Full explanation of the batch code (second code in the first post). Do not copy this to use in the batch file, it will not work. I used Lua commenting instead of Batch commenting and Windows will not run this. Batch commenting is confusing to those who aren't familiar with code, so I tried to make this readable.

    Code:
     -- location for the three folders: WoW logs, WoW other, and WoW WTF
    set $doc=S:\Documents
    
     -- location for screenshots
    set $pic=S:\Pictures
    
     -- batch setting that allows variables to be edited and used within the same loop
    setlocal enableDelayedExpansion
    
     -- searches running programs for wow
    tasklist | findstr /i /c:"wow.exe" /c:"wow-64.exe"
    
     -- cancels script if wow is still running
    if %errorlevel% equ 0 exit
    
     -- changes focus of script to the Logs folder
    cd /d "%~dp0Logs"
    
     -- Step 1) checks for a recent chat log, skips to combat check if not there
    if not exist WoWChatLog.txt goto combat
    
     -- Step 2) if a chat log exists, check if its empty, and if it is, force-write it to clear file dates, delete it, then go to combat
    for %%S in (WoWChatLog.txt) do if %%~zS equ 0 type nul > WoWChatLog.txt & del /f /q WoWChatLog.txt & goto combat
    
     -- Step 3) now that the chat log exists and has text in it, count all the saved chat logs including the new one
    for /f %%C in ('dir /b WoWChatLog*.txt ^| find /c /v ""') do set $num=%%C
    
     -- Step 4) delete ChatLog1 if there are 1000 or more chat logs, bringing the total to 999
    if %$num% geq 1000 type nul > WoWChatLog1.txt & del /f /q WoWChatLog1.txt
    
     -- Step 5) simple counting variable for the loop below
    set $count=0
    
     -- Step 6) counting and renaming loop that will give the new log the highest number and shift everything one down if log1 was deleted
    for /f "tokens=*" %%T in ('dir /b /o:d WoWChatLog*.txt') do (
    
     -- ------- increase counting variable by 1 each loop
    set /a $count+=1
    
     -- ------- this is where "enableDelayedExpansion" comes into play, !$count! increases each loop
    ren %%T WoWChatLog!$count!.txt)
    
     -- the combat section, everything is the same as above, but for the combat logs
    :combat
    
     -- Step 1)
    if not exist WoWCombatLog.txt goto taint
    
     -- Step 2)
    for %%S in (WoWCombatLog.txt) do if %%~zS equ 0 type nul > WoWCombatLog.txt & del /f /q WoWCombatLog.txt & goto taint
    
     -- Step 3)
    for /f %%C in ('dir /b WoWCombatLog*.txt ^| find /c /v ""') do set $num=%%C
    
     -- Step 4)
    if %$num% geq 1000 type nul > WoWCombatLog1.txt & del /f /q WoWCombatLog1.txt
    
     -- Step 5)
    set $count=0
    
     -- Step 6)
    for /f "tokens=*" %%T in ('dir /b /o:d WoWCombatLog*.txt') do (
    
     -- -------
    set /a $count+=1
    
     -- -------
    ren %%T WoWCombatLog!$count!.txt)
    
     -- one more section, this time for taint.log, which is generated when an addon tries to do something the UI doesn't allow
    :taint
    
     -- Step 1)
    if not exist taint.log goto files
    
     -- Step 2)
    for %%S in (taint.log) do if %%~zS equ 0 type nul > taint.log & del /f /q taint.log & goto files
    
     -- Step 3)
    for /f %%C in ('dir /b taint*.log ^| find /c /v ""') do set $num=%%C
    
     -- Step 4)
    if %$num% geq 1000 type nul > taint1.log & del /f /q taint1.log
    
     -- Step 5)
    set $count=0
    
     -- Step 6)
    for /f "tokens=*" %%T in ('dir /b /o:d taint*.log') do (
    
     -- -------
    set /a $count+=1
    
     -- -------
    ren %%T taint!$count!.log)
    
     -- the file section, which copies everything else
    :files
    
     -- copies the .bat file to WoW other
    robocopy "%~dp0." "%$doc%\WoW other" *.bat
    
     -- copies the Fonts folder to WoW other
    robocopy "%~dp0Fonts" "%$doc%\WoW other\Fonts" /E
    
     -- copies all chat/combat logs to WoW logs
    robocopy "%~dp0Logs" "%$doc%\WoW logs" WoW*Log*.txt
    
     -- copies all taint logs to WoW logs
    robocopy "%~dp0Logs" "%$doc%\WoW logs" taint*.log
    
     -- copies screenshots to WoW screenshots
    robocopy "%~dp0Screenshots" "%$pic%\WoW screenshots"
    
     -- copies the Sound folder to WoW other
    robocopy "%~dp0Sound" "%$doc%\WoW other\Sound" /E
    
     -- restores any missing chat/combat logs back to WoW\Logs
    robocopy "%$doc%\WoW logs" "%~dp0Logs" WoW*Log*.txt
    
     -- restores any missing taint logs back to WoW\Logs
    robocopy "%$doc%\WoW logs" "%~dp0Logs" taint*.log
    
     -- restores the .bat file to WoW folder
    robocopy "%$doc%\WoW other" "%~dp0." *.bat
    
     -- restores the Fonts folder to WoW folder
    robocopy "%$doc%\WoW other\Fonts" "%~dp0Fonts" /E
    
     -- restores the Sound folder to WoW folder
    robocopy "%$doc%\WoW other\Sound" "%~dp0Sound" /E
    
     -- restores any missing screenshots to WoW\Screenshots
    robocopy "%$pic%\WoW screenshots" "%~dp0Screenshots"
    
     -- changes focus of script to the WoW WTF folder at wherever you put the path at the very top of this script
    cd /d "%$doc%\WoW WTF"
    
     -- creates a blank WTF folder there
    md WTF
    
     -- counts the saved WTF folders
    for /f %%C in ('dir /b WTF* ^| find /c /v ""') do set $num=%%C
    
     -- deletes the oldest WTF save if there are 10, just like Step 4 in the logs
    if %$num% geq 10 rd /s /q WTF1
    
     -- another counting variable
    set $count=0
    
     -- another counting and renaming loop, does the same thing as the logs
    for /f "tokens=*" %%T in ('dir /b /o:d WTF*') do (
    
     -- -------
    set /a $count+=1
    
     -- -------
    ren %%T WTF!$count!)
    
     -- now that the new WTF folder has the highest number, the last thing the script does is copy the real WTF folder to this new WTF# folder
    robocopy "%~dp0WTF" "%$doc%\WoW WTF\WTF%$count%" /E
    Last edited by Kanegasi; 2017-11-28 at 02:41 PM.
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  7. #7
    I have another solution where I use a git repository to save my WTF folder contents. Basically my WoW icon on the desktop points to a wow-launcher.bat file and it's contents are following:
    Code:
    @echo off
    
    cd "C:\Program Files (x86)\Battle.net"
    start Battle.net Launcher.exe
    
    cd /D "E:\Games\World of Warcraft\WTF"
    git add .
    git commit -am "Scheduled commit"
    git push
    
    exit

    I use a free Bitbucket account for this and all the WTF folder changes are automatically added to my git repository. Now if something happens to my addon settings then all I have to do is delete the corrupted WTF folder and then just type this command to the console:
    Code:
    git clone https://raggamasta@bitbucket.org/raggamasta/wtf.git
    Last edited by Raggamasta; 2017-05-30 at 01:15 PM.

  8. #8
    Added Local Security Policy note at the bottom of the first post.
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  9. #9
    Quote Originally Posted by Kanegasi View Post
    Added Local Security Policy note at the bottom of the first post.
    Group Policy Editor is not enabled in Windows 10 Home or earlier non-pro or better versions.

    However at least in Windows 10 home it is available, but just disabled and this page gives a way to enable it again.

    https://www.askvg.com/how-to-enable-...rter-editions/
    Quote Originally Posted by DeadmanWalking View Post
    Your forgot to include the part where we blame casuals for everything because blizzard is catering to casuals when casuals got jack squat for new content the entire expansion, like new dungeons and scenarios.
    Quote Originally Posted by Reinaerd View Post
    T'is good to see there are still people valiantly putting the "Ass" in assumption.

  10. #10
    Quote Originally Posted by ComputerNerd View Post
    Group Policy Editor is not enabled in Windows 10 Home or earlier non-pro or better versions.

    However at least in Windows 10 home it is available, but just disabled and this page gives a way to enable it again.

    https://www.askvg.com/how-to-enable-...rter-editions/
    Well that's silly. I'm glad I have Pro. I can't imagine being artificially locked out of something on my own computer.
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •