Jump to content

How I can convert "BATCH ErrorLevel code" into AutoIT Script?


 Share

Recommended Posts

Hi i'm looking for include into my AutoIT script a test to a file that tell me when my XP VirtualMachine

is ready (WinLogon)

I must create a loop WHILE...WEND until ERROLEVEL is "1" and exit loop when is not "1".

But how i can include test to DOS errorlevel ??

I have searched on WEB and i have found and readed this informations:

- Function _ProcessExitCode() downloaded but running it --> tell me nothing on the state of file.

- Exit[return code]

- @exitCode ..... but i haven't found informaion how use it

- @exitMethod ... similar previou, i haven't found information how use it

For this moment i have realized a Mix of Batch and Au3 doing a loop in file BATCH, that verify if exist a file in VirtualMachine (not possible use AutoIT function "fileexists" --file is not in any folder-- but i must use a command of VirtualBox that do this)

The command answers with a DOS code of ErrorLevel="1" if file doesn't exists.

Now i have compiled the batch file to EXE file and then i have included it in AU3 script

in this mode:

============ WinLogonTest.BAT that i compiled into WinLogonTest.EXE ==========

@echo off

:CheckWinLogon

app64\vboxmanage --nologo guestcontrol "WinXP" stat "C:\Windows\Win.ini" --username "MyName"

REM If errorlevel is "1" the file Win.INI in Virtual Machine doesn't exist therefore Windows is not ready

If errorlevel==1 Goto CheckWinLogon

REM Now Windows is Ready "WinLogon it's done" and exit Loop

Exit

=================================================================================

####### Start.Au3 ##########

Run("WinLogonTest.exe") ; Batch Compiled that test WinLogon

Run("VirtualMachine....")

While processexists("WinLogonTest.exe")

sleep(250)

Wend

Msgbox(0, "", "Virtual Machine Ready, Script resume)

....

......

##############################

Please give me some suggestions or links to learn ho can use only AutoIT script.

Thanks

Link to comment
Share on other sites

DOS errorlevel is return code of the last called program.

In AutoIt you can use RunWait to start a program, wait until the program ends and get the return code. Example:

$iReturnCode = RunWait(@WindowsDir & "notepad.exe", @WindowsDir, @SW_MAXIMIZE)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

:D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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