Wise - Using a variable for Application Exit Code
I'm using Wise Installation System 9.02
I want to have my script execute another program, and should it fail will an exit code other than 0, I want my script to exit with the same error code.
Put another way, if I call MSIExec to install an application and the installation fails with exit code 1603, I want to exit my wise script with exit code 1603.
Is there any way to use a variable for the Application Exit Code? Does anyone have any other ideas?
I want to have my script execute another program, and should it fail will an exit code other than 0, I want my script to exit with the same error code.
Put another way, if I call MSIExec to install an application and the installation fails with exit code 1603, I want to exit my wise script with exit code 1603.
Is there any way to use a variable for the Application Exit Code? Does anyone have any other ideas?
0 Comments
[ + ] Show comments
Answers (10)
Please log in to answer
Posted by:
nortonl
15 years ago
You can do this using the 'ExitProcess' Windows API function (it terminates the current process and allows you to specify the exit code).
Set a variable e.g. EXITCODE in your Mainline event code as required, e.g. after calling MSIEXEC, Set variable EXITCODE to %INSTALL_RESULT%.
In the Wise Script editor, select the 'Exit' event (this runs when an Exit Installtion command is used).
Add a 'Call DLL Function' command:
[blockquote]
DLL Pathname=%SYS32%\kernel32.dll
Function Name=ExitProcess
Select 'Call a function with variable parameter list'
Add parameter:
[blockquote]
Parameter Type=long
Passing Type=Normal
Value Source=Variable
Variable Name=EXITCODE[/blockquote]
Return Value Type=long[/blockquote]
Some more info on the Windows function
One thing to remember - the exit code integer specified in the Wise Exit Installation command will be ignored, so you if you want to control the exit code within your code, you need to remember to set the EXITCODE variable before exiting.
Set a variable e.g. EXITCODE in your Mainline event code as required, e.g. after calling MSIEXEC, Set variable EXITCODE to %INSTALL_RESULT%.
In the Wise Script editor, select the 'Exit' event (this runs when an Exit Installtion command is used).
Add a 'Call DLL Function' command:
[blockquote]
DLL Pathname=%SYS32%\kernel32.dll
Function Name=ExitProcess
Select 'Call a function with variable parameter list'
Add parameter:
[blockquote]
Parameter Type=long
Passing Type=Normal
Value Source=Variable
Variable Name=EXITCODE[/blockquote]
Return Value Type=long[/blockquote]
Some more info on the Windows function
One thing to remember - the exit code integer specified in the Wise Exit Installation command will be ignored, so you if you want to control the exit code within your code, you need to remember to set the EXITCODE variable before exiting.
Posted by:
yarborg
18 years ago
You should be able to use the PROCEXITCODE variable in Wise when you execute another application. When you choose the script piece for "Execute program" make sure you check the "Wait" box and for the variable choose PROCEXITCODE. This should capture the exit code of the program you just called.
Hope that helps.
Hope that helps.
Posted by:
BoyGenius
18 years ago
That part isn't the problem. I don't have any problem determining the exit code of the called program, the issue is with the Exit function in Wise. It won't let me set the Application Exit Code programatically duing execution (at least I haven't figured out how).
When using the exit command, it demands that you enter an non-negative integer, and won't let me enter a variable name.
When using the exit command, it demands that you enter an non-negative integer, and won't let me enter a variable name.
Posted by:
BoyGenius
17 years ago
While its not a cools as passing INSTALL_RESULT as the wrapper's exit code, I've found a happy medium:
I've configured my program to use an .MIF (I've never bothered to before). Now, if the installation launched by my wrapper exits with a code other than 0, my wrapper still exits with an exit code that means nothing, but I can include the results of INSTALL_RESULT in the text written to the .MIF.
...at least I think I can. I've just started testing.
I've configured my program to use an .MIF (I've never bothered to before). Now, if the installation launched by my wrapper exits with a code other than 0, my wrapper still exits with an exit code that means nothing, but I can include the results of INSTALL_RESULT in the text written to the .MIF.
...at least I think I can. I've just started testing.
Posted by:
mupdike
15 years ago
Can you tell me how you were able to create a .mif with your WiseScript to accomplish this? While I am still hoping I will find something that will allow me to exit with the appropriate code (after all that capability makes sense when used as a wrapper) I am researching alternate reporting methods.
Thank you!
Thank you!
Posted by:
anonymous_9363
15 years ago
Posted by:
mupdike
15 years ago
I knew there was a risk in resurrecting this old of a post. I was hoping that someone had a good link or method already doc'd that could be shared. I've been googling the issue, of course, and have found a few links with some potential but still hoped to find something a bit more concrete here.
Thanks!
Thanks!
Posted by:
nortonl
15 years ago
Posted by:
nortonl
15 years ago
Posted by:
norexx
15 years ago
Fyi: Late to the party here (and resurrecting this thread for the third time), but just tried nortonl's method. Am happy to report it works great, and --even better-- much simpler than messing with .mif files.
I also found a handy VBscript someone posted to verify the Execute Program's "%INSTALL_RESULT%" value is really being passed along as the "wrapper" EXE's final exit code:
https://www-secure.symantec.com/community/download/10831/vbscript-install-application-exit-code
Hope this helps!
I also found a handy VBscript someone posted to verify the Execute Program's "%INSTALL_RESULT%" value is really being passed along as the "wrapper" EXE's final exit code:
https://www-secure.symantec.com/community/download/10831/vbscript-install-application-exit-code
Hope this helps!
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.