Jump to content
Sign in to follow this  
apollo13

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

Recommended Posts

apollo13

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

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water
:D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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  

×