Page 1 of 1

How to shutdown the computer automatically after a render

PostPosted: Thu Apr 15, 2021 6:04 pm
by Videoneth
Shrinivas Ramani wrote:Hi

Resolve 17 has the option for a post-render script (Render Settings > Advanced > Trigger Script at end of render job). You can queue up your render jobs, add a script to the last job in the queue and use that script to set your system to sleep/shutdown/spin-down drives, or even send an email notification so someone can push a button.

Please refer to the What's New in Resolve 17 document (starting page 349)

Regards
Shrinivas

So for people on Windows 10
(I'm sure there are other commands, I don't know, but this works for me) :

1) Create a LUA script with this code in it (just use the notepad) :
Code: Select all
manager = resolve:GetProjectManager()
manager:SaveProject()
strProgram = '"C:\\Windows\\System32\\shutdown.exe" /s /t 00'
os.execute(strProgram)

2) Put the file in C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Deliver - and call it "Shutdown.lua" for example

The first two lines will make Resolve save your project, then it will shut down the computer directly.
/t 00 is the time before the shutting down process (in seconds). You can delay it by giving a duration in seconds.

You can find all the other options here : https://docs.microsoft.com/en-us/window ... s/shutdown

I don't know the commands for Linux or MacOS, but I'm sure it can be found very easily.

I'm sure there are tons of other possibilities, like playing an audio notification, etc. anything that can be triggered by a script.

PS.
Don't test it like I did, with all my applications opened and work not saved :lol:

How to shutdown the computer automatically after a render

PostPosted: Thu Apr 15, 2021 9:02 pm
by TYKHAN
Working fine thanx.
Btw does this close davinci resolve AND shutdown the pc?

Sent from my iPhone using Tapatalk

Re: How to shutdown the computer automatically after a rende

PostPosted: Thu Apr 15, 2021 11:05 pm
by Marc Wielage
What I've done for years is ballpark-guess how long the render will take, then set an OS timer that adds another hour to that time (for safety) and shuts down the system. If Resolve is finished, it will allow the OS to safely exit the program and shut down, provided you have nothing else running (like an unsaved document in the background).

Re: How to shutdown the computer automatically after a rende

PostPosted: Thu Apr 15, 2021 11:50 pm
by Videoneth
TYKHAN wrote:Working fine thanx.
Btw does this close davinci resolve AND shutdown the pc?

Sent from my iPhone using Tapatalk


This particular one is just sending a signal to shut down the whole computer, regardless of what's oppened (the same way you would do from the start menu).

I added two lines at the beginning of the code. It will save your current project (in Resolve) before shutting down the computer.

Re: How to shutdown the computer automatically after a rende

PostPosted: Thu Apr 15, 2021 11:56 pm
by Videoneth
Marc Wielage wrote:What I've done for years is ballpark-guess how long the render will take, then set an OS timer that adds another hour to that time (for safety) and shuts down the system. If Resolve is finished, it will allow the OS to safely exit the program and shut down, provided you have nothing else running (like an unsaved document in the background).

You can try it, by changing 00 by 3600, so it would wait one hour before shutting down (I didn't test anything else than the immediate shut down)

Re: How to shutdown the computer automatically after a rende

PostPosted: Fri Apr 16, 2021 1:58 pm
by Videoneth
I added two lines to the code so the project is saved beforehand.
Code: Select all
manager = resolve:GetProjectManager()
manager:SaveProject()
strProgram = '"C:\\Windows\\System32\\shutdown.exe" /s /t 00'
os.execute(strProgram)

Re: How to shutdown the computer automatically after a rende

PostPosted: Fri Apr 16, 2021 8:23 pm
by Phil999
thank you Maxwellx.

Re: How to shutdown the computer automatically after a rende

PostPosted: Mon Apr 19, 2021 3:28 pm
by Thom Guida
Phil999 wrote:thank you Maxwellx.


Dittos

"I now dub thee, Maxwellx Smart."

*Google* Maxwell Smart for the reference/joke.

Re: How to shutdown the computer automatically after a rende

PostPosted: Sun Sep 05, 2021 10:35 pm
by Videoneth
Thom Guida wrote:
Phil999 wrote:thank you Maxwellx.


Dittos

"I now dub thee, Maxwellx Smart."

*Google* Maxwell Smart for the reference/joke.

lol

Re: How to shutdown the computer automatically after a rende

PostPosted: Tue Sep 07, 2021 9:56 pm
by jamedia
Maxwellx wrote:I added two lines to the code so the project is saved beforehand.
Code: Select all
manager = resolve:GetProjectManager()
manager:SaveProject()
strProgram = '"C:\\Windows\\System32\\shutdown.exe" /s /t 00'
os.execute(strProgram)


If the timeout period is greater than 0, the /f parameter is implied.
/f Forces running applications to close without warning users.

The best option might be to change the line to strProgram = '"C:\\Windows\\System32\\shutdown.exe" /s /t 30'
so that it starts the shutdown program with 30 second delay.
Then add a line to close Resolve
Code: Select all
Quit()

This will end the script and close Resolve but won't stop the running shutdown program which will shut down after resolve is closed.

Re: How to shutdown the computer automatically after a rende

PostPosted: Wed Sep 08, 2021 11:23 am
by capthook
good stuff - very useful
better than using a shortcut C:\Windows\System32\shutdown.exe -s -t xx and guessing for xx,
that I've used in the past, like MarC.
Speed Warp etc can add varying 'extra' time to the render so....
Your method is 'keyed' by Resolve finishing render - nice.
Thanks!
(and oh, the file *does* need to be .lua - not .txt for Resolve to recognize it, as you suggested)

Re: How to shutdown the computer automatically after a rende

PostPosted: Wed Jun 21, 2023 9:39 am
by alelom
Very useful thanks!

Just adding that you can also have a "hibernate" script by doing "shutdown /h" instead:

Code: Select all
manager = resolve:GetProjectManager()
manager:SaveProject()
strProgram = '"C:\\Windows\\System32\\shutdown.exe" /h'
os.execute(strProgram)


(This requires to have hibernate enabled in Windows.)

Cheers!

Re: How to shutdown the computer automatically after a rende

PostPosted: Thu Aug 17, 2023 1:55 pm
by docdoc
Very nice! Is there also a script like this for Mac?

Re: How to shutdown the computer automatically after a rende

PostPosted: Thu Aug 17, 2023 5:07 pm
by jamedia
docdoc wrote:Very nice! Is there also a script like this for Mac?


It should be equally simple to do for a POSIX OS.
Just google scripting for Mac.
It is worth learning basic scripting