Sign in to follow this  
Followers 0
jronex

Continue Script after reboot

18 posts in this topic

Was wondering if there was a good way to continue running a autoit script after reboot. My initial thought was to call and load my script in stages and put it in the startup folder in windows and at the final stage del the script from the startup folder. The application i'm trying to automated the installation for requires for 3 reboots.

Any ideas would be appreciated,

TIA!!

Share this post


Link to post
Share on other sites



place place it in the startup folder

have it write to a file

task 1 complete

task 2 complete

when started ... it reads the file and knows whats next

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

hmm, it depends on the app you'd like to install, but can't you "delay" the reboot?

or just don't close the last install-window, leave it open 'till you're done...

Not if he is automating the clicks of an install process that wont startup again until next reboot. 3 times.

:)

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

here is a model script I use for installs that take multiple reboots and requier elevated rights:

; pgm name DEMO.AU3
$Userid = "Administrator"
$Psw = "adminpsw"
; Remove autologin params from registry to clean up
SetAutoLogon("Off", "")
;
; retrieve param
$param1 = ""
If $CmdLine[0] > 0 Then
    $param1 = $CmdLine[1]
EndIf
; Act on it
Select
    Case $param1 = ""
        ; run your programs with admin account if needed in the first step
        RunAsSet($Userid, @ComputerName, $Psw)
        ;
        ; *** put your stuff here for step1 ***
        RunWait("notepad.exe step1.txt")
        ;
        SetAutoLogon("On", "step1")
        Shutdown(6)
    Case $param1 = "step1"
        ; is already logged on with admin account
        ;
        ; *** put your stuff here for step2 ***
        RunWait("notepad.exe step2.txt")
        ;
        SetAutoLogon("On", "step2")
        Shutdown(6)
    Case $param1 = "step2"
        ; logoff the admin account
        ; *** put your stuff here for step3 ***
        RunWait("notepad.exe step3.txt")
        ; just logoff
        Shutdown(0)
        Exit
EndSelect
Exit
;
;
Func SetAutoLogon($sw, $step)
    If $sw = "On" Then
        ; set the registry to start this program again after reboot
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUN", "Demo", "REG_SZ", @ScriptFullPath & " " & $step)
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "AutoAdminLogon", "REG_SZ", "1")
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultDomainName", "REG_SZ", EnvGet("LOGONSERVER"))
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultUserName", "REG_SZ", $Userid)
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultPassword", "REG_SZ", $Psw)
    EndIf
    ;
    If $sw = "Off" Then
        ; Remove the registrykey to start this program again after reboot
        RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUN", "Demo")
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "AutoAdminLogon", "REG_SZ", " ")
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultDomainName", "REG_SZ", " ")
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultUserName", "REG_SZ", " ")
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultPassword", "REG_SZ", " ")
    EndIf
EndFunc   ;==>SetAutoLogon
1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

hmm, it depends on the app you'd like to install, but can't you "delay" the reboot?

or just don't close the last install-window, leave it open 'till you're done...

i really dont know, it depends on the program you are installing and what it does...

but either way... thats not a good idea

my suggestion could work for this

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

installing MSDE so it requires a reboot for the next part of the installation. otherwise i would do what you suggested and close the other windows

hmm, it depends on the app you'd like to install, but can't you "delay" the reboot?

or just don't close the last install-window, leave it open 'till you're done...

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

awwwsooome i will try this..... and gets me pointed in the right direction . Thanks again for your feedback

Edited by jronex

Share this post


Link to post
Share on other sites

Below is the code that i modified to try to do reboots, but what is happening is that it try's to write to the appropriate step1.txt file and then fails to write file but able to do the reboot and does not continue script after reboot.

thanks,

;Main

$Userid = "user"
$psw = "password";
SetAutologon("Off","")

;retrieve parameters
$param1=""
IF $CmdLine[0] > 0 Then
    $param1=$CmdLine[1]
EndIf

;Act on it 
Select
    Case $param1 = ""
    ;RunAsSet ($Userid, @ComputerName, $psw)
    ;This calls the first stip of the instllation; IE 6 Installation
        Run("\\10.140.66.63\production scripts\PFAMcinstallpart1.exe", "\\10.140.66.63\production scripts\")
    ;I'm using notepad here as a pointer for the program
        RunWait("notepad.exe step1.txt")
        SetAutologon("On","step1")
        Shutdown(6)

    Case $param1="step1"
    ;This calls the 2nd step of the installation; Java,dot.net fix, and MSDE Installation          Run("\\10.140.66.63\production scripts\PFAMcinstallpart2.exe", "\\10.140.66.63\production scripts\")     Runwait("notepad.exe step2.txt")
        SetAutologon("On","Step2")
        Shutdown(6)

Case $param1="step2"
    ;This calls the 3rd step of the installation; Mobile Client Installation
        Run("\\10.140.66.63\production scripts\part3.exe", "\\10.140.66.63\production scripts\")
        RunWait("notepad.exe step3.txt")
        SetAutologon("On","step3")
        Shutdown(6)

    Case $param1="step3"
    ;This calls the 4th step of the installation: Mobile Notes Upgrade Installation
            Run("\\10.140.66.63\production scripts\partiv.exe", "\\10.140.66.63\production scripts\")
        RunWait("notepad.exe step4.txt")
        SetAutologon("On","step4")
        Shutdown(6)

    Case $param1="step4"
    ;This calls the 5th step of the installation;Regserv Part
        Run("\\10.140.66.63\production scripts\partvi.exe", "\\10.140.66.63\production scripts\")
        RunWait("notepad.exe step5.txt")
        SetAutologon("On","step5")
        Shutdown(6)

    Case $param1="step5"
    ;This calls the 6th step of the installation;SigPad Installation
        Run("\\10.140.66.63\production scripts\partvii.exe", "\\10.140.66.63\production scripts\")
        RunWait("notepad.exe step6.txt")
    ;just log off
        Exit
EndSelect

    

Func SetAutologon($sw, $step)
    if $sw = "On" Then 
    ; set the registry to start this program again after reboot     RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","automationscript","REG_SZ", @ScriptFullPath & "" & $step)
    ;setting the registry for autoadminlogin key to 1 for true
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Winlogon\", "AutoAdminLogon","REG_SZ","1")
    ;setting the registry for to default to the local domain name 
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultDomainName", "REG_SZ", EnvGet("LOGONSERVER")
    ;settting the registry for the default user id 
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows_NT\CurrentVersion\Winlogon\", "DefaultUserName", "REG_SZ", $Userid)
    ;setting the registry for the default password
    RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows_NT\CurrentVersion\Winlogon\", "DefaultPassword", "REG_SZ", $psw)
    EndIf
;

If $sw = "Off" Then
;Remove the registrykey to start this program again after reboot
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","automationscript")
;setting the registry for autoadminlogin key to 1 for true
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Winlogon\", "AutoAdminLogon","REG_SZ","")
;settting the registry for the default user id 
    RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows_NT\CurrentVersion\Winlogon\", "DefaultUserName", "REG_SZ", "")
;setting the registry for the default password
    RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows_NT\CurrentVersion\Winlogon\", "DefaultPassword", "REG_SZ", "")
EndIf
EndFunc
;

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

is this code on one line ??

; set the registry to start this program again after reboot     RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","automationscript","REG_SZ", @ScriptFullPath & "" & $step)oÝ÷ ÚÈhºW[{ibë(­élzØ^®éâ²}ý¶Ç­jëh×6    ; set the registry to start this program again after reboot     
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","automationscript","REG_SZ", @ScriptFullPath & "" & $step)
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Not sure what you mean but it's a registry delet command and not a run command??

is this code on one line ??

; set the registry to start this program again after reboot     RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","automationscript","REG_SZ", @ScriptFullPath & "" & $step)oÝ÷ ÚÈhºW[{ibë(­élzØ^®éâ²}ý¶Ç­jëh×6    ; set the registry to start this program again after reboot     
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","automationscript","REG_SZ", @ScriptFullPath & "" & $step)

Share this post


Link to post
Share on other sites

ohh i see now, what you mean; it is 2 lines the ; is not affecting the command .. sorry!

Not sure what you mean but it's a registry delet command and not a run command??

Share this post


Link to post
Share on other sites

Not sure what you mean but it's a registry delet command and not a run command??

No idea what you mean... but in your posted code the RegWrite is behind a comment in stead on a seperate line....

Maybe you can attach the script so i can verify if it is correct ...


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Below is the code that i modified to try to do reboots, but what is happening is that it try's to write to the appropriate step1.txt file and then fails to write file but able to do the reboot and does not continue script after reboot.

Another way is to split your script.

1. run Script1 -> write regkey to start script2 and autologon -> reboot

2. run Script2 -> ...

Share this post


Link to post
Share on other sites

below is the code ,

;
$Userid = "user"
$psw = "password1";fake psw
SetAutologon("Off","")


;retrieve parameters
$param1=""
IF $CmdLine[0] > 0 Then
    $param1=$CmdLine[1]
EndIf

;Act on it 
Select
    Case $param1 = ""
    ;RunAsSet ($Userid, @ComputerName, $psw)
    ;This calls the first stip of the instllation; IE 6 Installation
        Run("\\10.140.66.63\production scripts\PFAMcinstallpart1.exe", "\\10.140.66.63\production scripts\")
    ;I'm using notepad here as a pointer for the program
        RunWait("notepad.exe step1.txt")
        SetAutologon("On","step1")
        Shutdown(6)
    Case $param1="step1"
    ;This calls the 2nd step of the installation; Java,dot.net fix, and MSDE Installation
        Run("\\10.140.66.63\production scripts\PFAMcinstallpart2.exe", "\\10.140.66.63\production scripts\")
        Runwait("notepad.exe step2.txt")
        SetAutologon("On","Step2")
        Shutdown(6)
    Case $param1="step2"
    ;This calls the 3rd step of the installation; Mobile Client Installation
        Run("\\10.140.66.63\production scripts\part3.exe", "\\10.140.66.63\production scripts\")
        RunWait("notepad.exe step3.txt")
        SetAutologon("On","step3")
        Shutdown(6)
    Case $param1="step3"
    ;This calls the 4th step of the installation: Mobile Notes Upgrade Installation
        Run("\\10.140.66.63\production scripts\partiv.exe", "\\10.140.66.63\production scripts\")
        RunWait("notepad.exe step4.txt")
        SetAutologon("On","step4")
        Shutdown(6)
    Case $param1="step4"
    ;This calls the 5th step of the installation;Regserv Part
        Run("\\10.140.66.63\production scripts\partvi.exe", "\\10.140.66.63\production scripts\")
        RunWait("notepad.exe step5.txt")
        SetAutologon("On","step5")
        Shutdown(6)
    Case $param1="step5"
    ;This calls the 6th step of the installation;SigPad Installation
        Run("\\10.140.66.63\production scripts\partvii.exe", "\\10.140.66.63\production scripts\")
        RunWait("notepad.exe step6.txt")
    ;just log off
        Exit
EndSelect
    
Func SetAutologon($sw, $step)
#comments-start**************************************************
This section of the code sets the autologing paramameters.  
#comments-end****************************************************
    if $sw = "On" Then 
    ; set the registry to start this program again after reboot 
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","automationscript","REG_SZ", @ScriptFullPath & "" & $step)
    ;setting the registry for autoadminlogin key to 1 for true
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Winlogon\", "AutoAdminLogon","REG_SZ","1")
    ;setting the registry for to default to the local domain name 
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultDomainName", "REG_SZ", EnvGet("LOGONSERVER")
    ;settting the registry for the default user id 
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows_NT\CurrentVersion\Winlogon\", "DefaultUserName", "REG_SZ", $Userid)
    ;setting the registry for the default password
        RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows_NT\CurrentVersion\Winlogon\", "DefaultPassword", "REG_SZ", $psw)
    EndIf
;
#comments-start**************************************************
This section of the code removes the autologing paramameters.   
#comments-end****************************************************

If $sw = "Off" Then
;Remove the registrykey to start this program again after reboot
    RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","automationscript")
;setting the registry for autoadminlogin key to 1 for true
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Winlogon\", "AutoAdminLogon","REG_SZ","")
;settting the registry for the default user id 
    RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows_NT\CurrentVersion\Winlogon\", "DefaultUserName", "REG_SZ", "")
;setting the registry for the default password
    RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows_NT\CurrentVersion\Winlogon\", "DefaultPassword", "REG_SZ", "")
EndIf
EndFunc
;

Share this post


Link to post
Share on other sites

can you give me an example of how that script wiil look

so i'm guessing i would just split my script and add the following code

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","script2.exre","REG_SZ", @ScriptFullPath)
;

Another way is to split your script.

1. run Script1 -> write regkey to start script2 and autologon -> reboot

2. run Script2 -> ...

Share this post


Link to post
Share on other sites

can you give me an example of how that script wiil look

so i'm guessing i would just split my script and add the following code

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","script2.exre","REG_SZ", @ScriptFullPath)
;
Yes that's all.

If you want to autologon after reboot, write the keys

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","AutoAdminLogon|DefaultDomainName|DefaultPassword|DefaultUserName","REG_SZ", "1|Domain|Password|UserName")

Share this post


Link to post
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
Sign in to follow this  
Followers 0