Fixed the problem by searching around on the forum.
This is how i fixed it.
MsgBox(4096, "Toucan", "Toucan will run in 30 minutes!")
ProcessClose ( "InDesign.exe")
Run("C:\Windows\System32\rundll32.exe user32.dll, LockWorkStation")
Sleep(1800000)
Run("C:\PortableApps\Toucan\Toucan.exe Script SyncJob")
Sleep(1200000)
Sleep(1000)
If Shutdown(1 + 4 + 8 +16) = 1 Then
; 0 = Logoff; 1 = Shutdown; 2 = Reboot; 4 = Force; 8 = Power down; 16= Force if hung; 32= Standby; 64= Hibernate
FileWriteLog($Log_File, @YEAR & "/" & @MON & "/" & @MDAY & ";" & @HOUR & ":" & @MIN & ";Shutdown;Success")
; If Shutdown is a success a line will be added to the log_File. Exemple of such a line :
; 2009/01/11;21:53;Shutdown;Success
Else
FileWriteLog($Log_File, @YEAR & "/" & @MON & "/" & @MDAY & ";" & @HOUR & ":" & @MIN & ";Shutdown;Failure")
; If Shutdown is NOT a success a line will be added to the log_File. Exemple of such a line :
; 2009/01/11;21:53;Shutdown;Failure
EndIf
Sleep(1000)
Exit
Func FileWriteLog($sLogPath, $sLogMsg)
Local $hOpenFile
Local $hWriteFile
$hOpenFile = FileOpen($sLogPath, 1)
If $hOpenFile = -1 Then
SetError(1)
Return 0
EndIf
$hWriteFile = FileWriteLine($hOpenFile, $sLogMsg)
If $hWriteFile = -1 Then
SetError(2)
Return 0
EndIf
FileClose($hOpenFile)
Return 1
EndFunc