I changed my script so that the messagebox has a timer and when that timer stops, the shutdown is started immediately.

But the problem is still there. The PC won't shutdown if the PC is locked.

With some messages that are written in a textfile I could see that the problem is in the shutdown function.

Is there someone else who has a usefull tip to shutdon a PC?