This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- Re: Executing scripts
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 26, 2008
07:13 AM
Executing scripts
Hi,
I am working with InstallAnywhere 2008 Standard edition. I am using 'Execute Script/Batch file' option to execute few scripts to install various softwares. I would like to execute all these installation scripts based on the output of a script. I mean to say that if this script returns 'o' then execute all other scripts else if it returns '-1' then all other scripts should not be executed. Can anyone tell me how to acheive this?
Please get back to me for any further details.
Thanks in advance,
Regards,
IAUser123
I am working with InstallAnywhere 2008 Standard edition. I am using 'Execute Script/Batch file' option to execute few scripts to install various softwares. I would like to execute all these installation scripts based on the output of a script. I mean to say that if this script returns 'o' then execute all other scripts else if it returns '-1' then all other scripts should not be executed. Can anyone tell me how to acheive this?
Please get back to me for any further details.
Thanks in advance,
Regards,
IAUser123
(6) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 26, 2008
09:46 AM
The first Execute Script/Batch File action should set the value of an IA variable to the script return value ($EXECUTE_EXITCODE$, by default); you could then use that variable in a rule on subsequent script actions (or on an action group containing the other script actions).
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 27, 2008
04:00 AM
Hi,
Thanks for the reply. Could you please explain briefly on how to use the variable ($EXECUTE_EXITCODE$)?
Regards,
IAUser123
Thanks for the reply. Could you please explain briefly on how to use the variable ($EXECUTE_EXITCODE$)?
Regards,
IAUser123
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 27, 2008
09:12 AM
To use the value of a variable in a conditional statement, you can select the Rules tab in an action's customizer, click Add Rule, and select Compare InstallAnywhere Variables. In the rule's settings, then, you can compare $EXECUTE_EXITCODE$ with the desired return value.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 30, 2013
03:57 PM
I have been lurking in the IA forum and some other script/batch programming forums to figure out why I am not getting this to work.
[LIST=1]
Vitals
[LIST=a]
InstallAnywhere 2012 Enterprise Edtion with SP1 patch
Windows XP with SP3 patch applied
Desired workflow
[LIST=a]
In the Pre-Install actions, I did an Add Action -> Execute Script/Batch file:
I cut an paste my batch script into the panel after debugging it and making sure it works.
We are performing an upgrade in the field which means we are installing newer files over older ones.
The batch script's function is to ensure that a certain list of files has the read-only attribute set. If the attribute is not set for any of the files in question, that means we have a broken system and we don't want to do the upgrade.
My intent is for the script to exit with a non-zero return code and have that be captured in the $EXECUTE_EXITCODE$
Then I added a rule at the Install action to Compare InstallAnywhere Variables Numerically. I am comparing $EXECUTE_EXITCODE$(left parameter) to 0. In the bottom it says Perform only if: I presume that means perform the install only if $EXECUTE_EXITCODE$ is 0.
Trouble
[LIST=a]
For testing, I deliberately setup a system where the read-only attribute was unset for all of the artifacts we care about.
I ran the script outside of InstallAnywhere and it is properly logging the problem and exiting with a return code of 1.
When I run it inside of InstallAnywhere, it does the logging stuff correctly and bails out where it should but the return code is not being captured in $EXECUTE_EXITCODE$.
Now I found an entry from 2008 in which that user cautioned not to do exit /b 1 but do exit 1. He said the '/b' hoses things up. So, I removed the '/b' part from my script. No luck.
Then I saw another post on a Batch scripting forum in which someone recommeded @%COMPSPEC% /C exit 1. That didn't work either.
Question, how do I get the return code from the script captured into $EXECUTE_EXITCODE$. I am probably the gazillionth person to ask. Sorry ... New to batchscripting. Old Unix hand. And while I am at it, can I cut an paste a powershell script in this action, instead?
[LIST=1]
[LIST=a]
[LIST=a]
[LIST=a]
Question, how do I get the return code from the script captured into $EXECUTE_EXITCODE$. I am probably the gazillionth person to ask. Sorry ... New to batchscripting. Old Unix hand. And while I am at it, can I cut an paste a powershell script in this action, instead?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 30, 2013
04:42 PM
I knew I would find the answer after bugging you folks. See http://stackoverflow.com/questions/4632891/exiting-batch-with-exit-b-x-where-x-1-acts-as-if-command-completed-successfu.
The script has to look like this:
That works. The entry I saw at the link is:
I was confused for a bit, so this is just a note for others that you literally need that to be the last line of the file. It won't actually exit the batch, just set the error code. Calling EXIT /B %ERRORLEVEL% directly after it doesn't always seem to work either. The only reliable method I found was to use IF ERRORLEVEL 1 goto :end and have a label :end just before the last line with %COMSPEC% /C EXIT %ERRORLEVEL%>NUL – Jordan Evens Jan 10 '11 at 14:34
The script has to look like this:
cd $USER_INSTALL_DIR$
:: Get the list of files with the read-only attribute set.
:: This post-install script restores the read-only attribute
:: to the files in the list.
::
:: If the system encounters a system where there is not
:: read-only attribute set, bail out with an error.
dir /a:r-h /s /b>%AttrFile%
if %errorlevel% neq 0 (
call :complain "ERROR: %errorlevel% : read-only attribute not set for any file"
goto :end
)
....
:: Name : complain
::
:: Purpose : Issues error message to logfile.
::
:: Parameters :
:: msg - Error message handling
:: %1 - Error Message
::
:: Increments wmerrors
::
:complain
setlocal
(set msg=%~1)
set emsg="[%date% %time% %wmhost%] %msg%"
echo %emsg:~1,-1% >> %LogFile%
endlocal
goto :eof
...
:end
%comspec% /c exit %errorlevel%
:: Get the list of files with the read-only attribute set.
:: This post-install script restores the read-only attribute
:: to the files in the list.
::
:: If the system encounters a system where there is not
:: read-only attribute set, bail out with an error.
dir /a:r-h /s /b>%AttrFile%
if %errorlevel% neq 0 (
call :complain "ERROR: %errorlevel% : read-only attribute not set for any file"
goto :end
)
....
:: Name : complain
::
:: Purpose : Issues error message to logfile.
::
:: Parameters :
:: msg - Error message handling
:: %1 - Error Message
::
:: Increments wmerrors
::
:complain
setlocal
(set msg=%~1)
set emsg="[%date% %time% %wmhost%] %msg%"
echo %emsg:~1,-1% >> %LogFile%
endlocal
goto :eof
...
:end
%comspec% /c exit %errorlevel%
That works. The entry I saw at the link is:
I was confused for a bit, so this is just a note for others that you literally need that to be the last line of the file. It won't actually exit the batch, just set the error code. Calling EXIT /B %ERRORLEVEL% directly after it doesn't always seem to work either. The only reliable method I found was to use IF ERRORLEVEL 1 goto :end and have a label :end just before the last line with %COMSPEC% /C EXIT %ERRORLEVEL%>NUL – Jordan Evens Jan 10 '11 at 14:34
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)