How to control shutdown.exe? [Solved]

I’m trying to turn the computer off at the end of the day thanks touchdesigner.
I guess I can run a BAT file that included this code :

shutdown -h

But I can’t find the way to execute this file throw touchdesigner.

Does someone has already do this and could help me?

Thanks :wink:

You can try using pythons subprocess: … a-computer


Thank you Markus, :wink:

Does anyone know how to remove Windows’ warning when we use shutdown process?
Here a warning’ screen :

Have you tried using the force flag -f?

Yes :wink:
Here is the script I use :

I guess if I use an other timer like you wrote here Elburz, maybe it will work if I use :

import subprocess
script = '["shutdown", "-f", "-s", "-t", "0"])'
run(script, delayMilliSeconds = 10000)

EDIT : don’t forget to import subprocess ^^

That’s work ! :slight_smile:

hello there!

very cool, right what i was searching for!
but running into a (newbe…) problem:
the script attached runs great when i paste it into a text_dat and run the script by right-clicking and choose “run script”
but when i put the script into a chop_execute, nothing happens when chop value changes to 1…
how have i to execute a script in touch?
many thanks for a little hint!
best luca

ok, here’s a little scene with my problem to understand how to execute this script in the right way!
thank you for the insight…!
shutdown.4.toe (4.71 KB)

Make a new thread please. this one was solved.

import subprocess

def onValueChange(channel, sampleIndex, val, prev):

	script = '["shutdown", "-f", "-s", "-t", "0"])'
	run(script, delayMilliSeconds = 1)