Jump to content

Hot to continue that autoIT script after reboot


Recommended Posts

How I would do it is use an Ini file for each package for example:

[Package]
1=RunWait(@ScriptDir & '\Package1\Setup.exe /s')
2=RunWait(@ScriptDir & '\Package2\Setup.exe /s')

In your Au3 Script I would add a scheduled task that will run the script on logon until it completes something like:

#NoTrayIcon
#RequireAdmin

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
://////=__=
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Array.au3>
Global $sREG_PACKAGE = 'HKLM\SOFTWARE\Package'
Global $hINI_PACKAGE = @ScriptDir & '\Package.ini'
Global $aINI_SECTION = IniReadSection($hINI_PACKAGE, 'Package')
    If @error Then Exit
Global $iINI_SECTION = Number(RegRead($sREG_PACKAGE, 'Package'))
    If $iINI_SECTION = '' Then $iINI_SECTION = 1

;~ Create a Scheduled Task
RunWait(@ComSpec & ' /c SchTasks /Create /SC ONLOGON /TN "' & FileGetVersion(@ScriptFullPath, 'ProductName') & '" /TR "' @ScriptFullPath & '" /ru "Domain\User /rp "Password"', '', @SW_HIDE)

For $x = $iINI_SECTION To $aINI_SECTION[0][0]
    ConsoleWrite('RegWrite("' & $sREG_PACKAGE & '", "Package", "REG_SZ", "' & $aINI_SECTION[$x][0] & '")' & @CRLF)
    ConsoleWrite('_Execute(' & $aINI_SECTION[$x][1] & ')' & @CRLF)
Next
ConsoleWrite('RegDelete("' & $sREG_PACKAGE '")' & @CRLF)

;~ Delete the Scheduled Task
RunWait(@ComSpec & ' /c SchTasks /Delete /TN "' & FileGetVersion(@ScriptFullPath, 'ProductName') & '"', '', @SW_HIDE)

Func _Execute($hPKG_EXECUTE)
    Local $iPID_EXECUTE = Execute($hPKG_EXECUTE)
    While ProcessExists($iPID_EXECUTE)
        Sleep(100)
    WEnd
    ;~ Check for Reboot Requirements here
EndFunc

Just really thinking out of the box, haven't tested but should work.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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