Auto-restart blender after crash

Hi,

For a project I need to render alot of frames but because the scene is heavy blender crashes after 10 frames or so. Not a big deal but I want to render it overnight so i would be nice to be able to auto-restart blender and start rendering.

I found this old script on this page using autohotkey: https://blender.stackexchange.com/questions/41549/resuming-rendering-image-sequence-after-blender-crash

But I can’t get it to work with my scene…

#SingleInstance
TIMER = 5000
title=
file=
WinWaitActive, ahk_class GHOST_WindowClass
WinGetTitle, title, A
file := RegExReplace(title, ".*\[(.*)\]$", "$1")
if file=
{
    msgbox, CANNOT GET FILENAME FROM TITLE: "%title%"
    exitapp
}
TrayTip, blender, % "Now watching for " file
Loop
{
    IfWinNotExist, %title% ahk_class GHOST_WindowClass
    {
        IfWinExist, ahk_exe blender.exe
            goto next
        TrayTip, blender, % "Restarting " file
        Run, C:\Program Files\Blender Foundation\blender 2.90\blender.exe %file%
        WinWaitActive, ahk_class GHOST_WindowClass
        Sleep, 2000
        Send, ^{f12}
    }
next:
    Sleep TIMER
}
+0::exitapp

It tries to open blender but it then also closes and then it’s in this loop of opening en closing