Sign in to follow this  
Followers 0
abberration

StdoutRead with Inno Setup compiler

7 posts in this topic

Hello, all. Every month, I have to compile a lot of databases as installers for work. Sometimes, a few don't compile correctly and I would like to be able to log the failures. I am using AutoIt to start the compile process with Inno Setup's compiler. Inno's documentation says it will return a 0 or 1 depending on success or failure.

I have tried a lot of variations of this code and none of them have return anything. My first attempts was running the compiler directly (not @ComSpec). That didn't work either.

#include <CONSTANTS.AU3>
$compileProg = RunWait (@ComSpec & " /c " & "Compil32.exe /cc test.iss", "", "", $STDERR_CHILD + $STDOUT_CHILD)
$returnCode = StdoutRead ($compileProg)
MsgBox(0, "", $returnCode)

Does anyone have any suggestions?


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If it says "will return a 0 or a 1" you need to read the return code, not the StdOut.

The return code can be read by Run() or RunWait():

If you assign the result of Run / RunWait to a variable, that's your returncode.

$iReturnCode = Run("ping 127.0.0.1")
ConsoleWrite("RC:" & $iReturnCode & @CRLF)
$iReturnCode = Run("ping 127.0.0.10")
ConsoleWrite("RC:" & $iReturnCode & @CRLF)
Edited by hannes08

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

The exit code is not read when using Run, the code you get when you use Run is the PID. You only get a exit code using RunWait and ShellExecuteWait. There's no way for Run to get an exitcode because by the time the program you started has exited, the script has moved on.

BTW, don't use @ComSpec with RunWait if you want the exitcode of the program, because the exitcode you're going to get is the one from cmd.exe and not your program.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thanks for the advice guys, but I still can't get a return code. It's possible that it just can't be done.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

Try this

#include <CONSTANTS.AU3>
$returnCode = ''
$compileProg = Run (@ComSpec & " /c " & "Compil32.exe /cc test.iss", "", "", $STDERR_CHILD + $STDOUT_CHILD)
While ProcessExists($compileProg)
   $returnCode &= StdoutRead ($compileProg)
Wend
MsgBox(0, "", $returnCode)

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Try this

#include <CONSTANTS.AU3>
$returnCode = ''
$compileProg = Run (@ComSpec & " /c " & "Compil32.exe /cc test.iss", "", "", $STDERR_CHILD + $STDOUT_CHILD)
While ProcessExists($compileProg)
$returnCode &= StdoutRead ($compileProg)
Wend
MsgBox(0, "", $returnCode)

Thanks for the effort, but still no dice. I'll look at it agin tomorrow.

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

Are you still using @Comspec to run the program when you try it? See my last post if you are.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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