Auto-restart blender after crash


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:

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

TIMER = 5000
WinWaitActive, ahk_class GHOST_WindowClass
WinGetTitle, title, A
file := RegExReplace(title, ".*\[(.*)\]$", "$1")
if file=
    msgbox, CANNOT GET FILENAME FROM TITLE: "%title%"
TrayTip, blender, % "Now watching for " file
    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}
    Sleep TIMER

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