Jump to content

Recommended Posts

Posted (edited)

Hello,

I use a backup script for all my InDesign files using a freeware tool called toucan.

Now to make it work like i want it to i use AutoIt, everything works perfect except that my computer doesn't shutdown at the end of the script.

MsgBox(4096, "Toucan", "Toucan will run in 10 minutes!")
ProcessClose ( "InDesign.exe")
Run("C:\Windows\System32\rundll32.exe user32.dll, LockWorkStation")
Sleep(600000)
Run("C:\PortableApps\Toucan\Toucan.exe Script SyncJob")
Sleep(1000000)
Shutdown(1)

I also tried Shutdown(6) and Shutdown(9) but they don't work.

It is very important that my computer stays locked.

Thanks in advance,

Edited by mistermiggy
Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...