Jump to content

Windows ADK Fast Startup Autoit Test - Script help


Recommended Posts

Hi All,
Hello everyone, I would like to ask, currently I want to use Autoit to write "Windows ADK Fast Startup" Autoit Test,
but I don't know how to prevent the script from closing when Windows ADK Fast Startup is executed, or how to save the current state of the script before execution, and continue execution from the saved state after Windows ADK execution is completed.


Is there a good person who is willing to provide a script for me to learn from, thank you very much.

Link to comment
Share on other sites

3 hours ago, huan51415 said:

I don't know how to prevent the script from closing

you should not prevent the script from closing but in the 1st example it shows that you can save whatever setting you'd like to save from that function.
Unless you go into detail of what are you upto, this is all I'm gonna do.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

1 hour ago, argumentum said:

you should not prevent the script from closing but in the 1st example it shows that you can save whatever setting you'd like to save from that function.
Unless you go into detail of what are you upto, this is all I'm gonna do.

Hello argumentum,
I am inquiring about the usage of OnAutoItExitRegister(), but I still don’t know much about it, and I haven’t found relevant examples. Can you help explain the usage of OnAutoItExitRegister() in detail, sincere thanks.

Link to comment
Share on other sites

This is a basic prototype:

; Program starts here
; Maybe you want to check and load saved stuffs here
OnStart()

OnAutoItExitRegister('OnExit')

; Press ESC to exit the program
HotKeySet('{ESC}', 'Quit')

; Program code here
; ...

; Main loop to keep the program running
While True
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc

Func OnExit()
    ConsoleWrite('The program will close soon.' & @CRLF)
    ; Do your save stuffs here
EndFunc

Func OnStart()
    ConsoleWrite('The program just started.' & @CRLF)
    ; Do your load stuffs here
EndFunc

 

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

11 hours ago, Andreik said:

This is a basic prototype:

; Program starts here
; Maybe you want to check and load saved stuffs here
OnStart()

OnAutoItExitRegister('OnExit')

; Press ESC to exit the program
HotKeySet('{ESC}', 'Quit')

; Program code here
; ...

; Main loop to keep the program running
While True
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc

Func OnExit()
    ConsoleWrite('The program will close soon.' & @CRLF)
    ; Do your save stuffs here
EndFunc

Func OnStart()
    ConsoleWrite('The program just started.' & @CRLF)
    ; Do your load stuffs here
EndFunc

 

Thanks for the great help, I'll try and see if it helps me.
In addition, I would like to ask, if I want to set a storage point for a certain paragraph in the script, so that I can return to this storage point and continue to execute the script, how should I do it?

Link to comment
Share on other sites

23 minutes ago, Andreik said:

I am not sure what do you mean by storage point and script paragraphs.

Let's take an example:

; Program starts here
; Maybe you want to check and load saved stuffs here
OnStart()

;------save point

OnAutoItExitRegister('OnExit')

; Press ESC to exit the program
HotKeySet('{ESC}', 'Quit')

; Program code here
; ...

;------back to save point

; Main loop to keep the program running
While True
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc

Func OnExit()
    ConsoleWrite('The program will close soon.' & @CRLF)
    ; Do your save stuffs here
EndFunc

Func OnStart()
    ConsoleWrite('The program just started.' & @CRLF)
    ; Do your load stuffs here
EndFunc

;------back to save point

li

ke this

Link to comment
Share on other sites

1 hour ago, Andreik said:

Ok, but what kind of information do you want to save/load? Give me an example.

I need to judge that if the script execution is interrupted in the middle, I can continue execution from where it was interrupted.

Link to comment
Share on other sites

I don't know very much about Windows ADK so I can't help you unless you detail about what script are you talking about, what it's suppose to do and how would you normally detect if it's interrupted. Then we can find a solution with AutoIt.

When the words fail... music speaks.

Link to comment
Share on other sites

I imagine that you can have "steps" in your script, and a file which tracks which steps or the last step in the process the script has performed.  If this is part of an imaging process or some sort of task sequence, then you could log to either the local disk--if appropriate--or to a share folder.

Link to comment
Share on other sites

I still don't get where is AutoIt involved and what it's suppose to do. Is your AutoIt script related to Windows ADK or you simply want to run an AutoIt script after windows boot up and continue from where it was when windows shutdown?

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

It sounds like the goal is to write a benchmarking/processing/optimizing app in AutoIt for the evaluation of fast startup tests using the Windows Assessment Toolkit/Console. That sounds like a huge undertaking if you don't have reasonable command of the scripting language or how to articulate the process and goals of the script. 

Link to comment
Share on other sites

13 hours ago, Andreik said:

I still don't get where is AutoIt involved and what it's suppose to do. Is your AutoIt script related to Windows ADK or you simply want to run an AutoIt script after windows boot up and continue from where it was when windows shutdown?

Yes, I simply want to run an AutoIt script after windows boot up and continue from where it was when windows shutdown.

Link to comment
Share on other sites

It depends what kind of data do you want to save but here is a simple prototype. Basically I keep update the value of a variable named counter and save it's content when the program is closed due to windows restart/shutdown or the program is closed using tray icon. When the program is run after restart it will continue to count from the value previously saved.

; Program starts here
OnAutoItExitRegister('OnExit')

; Press ESC to exit the program
HotKeySet('{ESC}', 'Quit')

; Program code here
Global $iCount = 0

; Maybe you want to check and load saved stuffs here
OnStart()

; Main loop to keep the program running
While True
    $iCount += 1
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc

Func OnExit()
    ConsoleWrite('The program will close soon.' & @CRLF)
    ; Program will end soon, let's save our counter variable
    ConsoleWrite('Current count value: ' & $iCount & @CRLF)
    Local $hFile = FileOpen('current_state.dat', 2)
    FileWrite($hFile, $iCount)
    FileClose($hFile)
EndFunc

Func OnStart()
    ConsoleWrite('The program just started.' & @CRLF)
    ; Let's check if we have a file that saved out counter variable
    If FileExists(@ScriptDir & '\current_state.dat') Then
        $iCount = FileRead(@ScriptDir & '\current_state.dat')
        ConsoleWrite('I will continue from ' & $iCount & @CRLF)
    Else
        ConsoleWrite('There is no previous state saved.' & @CRLF)
    EndIf
EndFunc

This is a basic example but if you have more complex tasks like data received over TCP or some kind of data processing it' important to know what do you want and need to save in order to continue the task. In case of TCP there might be some wasted data so it would be useful to define specific save points in your code. When your program reach certain points you can save the current state. For saving current state I used a dat file but you can use ini files if it's more suitable for your case.

Edit: if your program is suppose to restart automatically after windows restart, probably it should be registered as a service.

Edited by Andreik

When the words fail... music speaks.

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...