Exit Code from Within Wise script
We're trying to define a baseline template script in wise for all our future scrpted installs. The script should execute the some preinstallation checks and then install the application in silent mode with progress bar and display a message at the end. And also return Exit Code to Altiris, depending upon the install result. Following the code template that i'm using.
=======================================
Set PROCEXITCODE to %PROCEXITCODE%
Pre installation checks like checking source file
Display Progress bar (show progress bar)
Execute Application (Wait)
Display Progress bar (close previous proogress bar)
Set Variable EXITCODE to %PROCEXITCODE%
if EXITCODE = 0 then
Exit Installation 0
Else
if EXITCODE = 3010 then
Exit Installation 3010
Else
Exit Installation 1
End
End
========================================
The issue here is EXIT INSTALLATION is accepting only NON NEGETIVE INTEGERS. For exit code 0 and 3010, its fine.
My real concern here is that there is no passing of variable to EXIT INSTALLATION.
For example in vbscript i can pass a variable to wscript.quit() function.
'=========================================
i = 0
i = wshell.run(execute application)
wscript.quit(i)
'=========================================
Is there any way to pass a variable as an EXIT CODE to Altiris instead of [Exit Installation 0] or [Exit Installation 3010] or [Exit Installation 1]? Any help is greatly appreciated.
Thank you for your time on this.
Thanks,
Eshwar
Comments
I'm also looking for the
I'm also looking for the same. Anybody?
No Elegant Solution
There is no elegant solution for this as the Exit Installation command does not permit a variable to be used - it insists on an actual value.
The only viable solution I can think of, is to have a long list of IF statements testing the variable and running the Exit Installation command with the appropriate hard coded value
If variable = 1
Exit Installation 1
End block
If variable = 2
Exit Installation 2
End block
and so on.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Thats what i'm doing now!In
Thats what i'm doing now!
In this case we have to predict the Error Code prior to execution. But situation araises when there is an error that is out of our imagination. I have an example here.
I was trying to install Adobe Photoshop CS4 application package with 0,1620,3010 and 1. But during testing i came accross 3221225478 error.
If we can capture the errors like above, it will be very useful for debugging. Anyway, thank you for your comment. I appreciate your time on this.
Thanks,
Eshwar
Debugging
What about restricting the error codes returned to a small subset of the standard error codes. Any error codes outside this set would return a single generic code (eg 111 or 999) and this would tell your subsequent code to look in a specific registry location where the actual error code would be written by your wisescript.
Bearing in mind that the return code from your Adobe app might also lie outside the range of integer values supported by Wisescript, it may be that the Exit Installation command may not handle such a large number without itself erroring out (although I admit I haven't tried it).
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
I always write the install
I always write the install success/failure with exit code to event log at the end of the install. That way, you can findout the exact error code from the machine eventlog.
Following the vbscript wrapper code i used for Adobe photoshop CS4 install:
i = 0
'EXECUTE Adobe Photoshop CS4
i = oShell.Run(sCmdLine, 1 ,True)
If (i = 0) Or (i = 3010) Then
'====================================================
'WRITE THE SUCCESS RESULT TO EVENT LOG
oShell.LogEvent vbLogSuccess, sLogHeader & "Installation completed successfully." & VbCrLf & "Exit code: " & i
'====================================================
'RUN ALTIRIS MACHINE INVENTORY
Call RunDailyMachineInventory
'DISPLAY INSTALLATION COMPLETION MESSAGE TO THE USER WITH STANDARD TIMEOUT
oShell.Popup + "Adobe Photoshop CS4 installation has been completed successfully.", TIMEOUT, POPUP_TITLE, vbOKOnly+vbInformation+vbSystemModal
WScript.Quit(i)
Else
'====================================================
'WRITE THE FAILURE RESULT TO EVENT LOG
oShell.LogEvent vbLogError, sLogHeader & "Installation returned failure code." & VbCrLf & "Exit code: " & i
'====================================================
'DISPLAY INSTALLATION FAILURE MESSAGE TO THE USER
MsgBox "The installation of " & sAppName & " returned an error: " & i & VbCrLf & _
"Please contact IT Support to report this error.", vbOKOnly, sAppName
End If
My question here is, is there anyway to write the exit code to EVENTLOG within WISE SCRIPT? I didn't find any option [may be i'm trying to be a NOOB :-)] in wise script to write an event to event log.
Thanks,
Eshwar
Use eventcreate.exe
Eshwar,
Check out the Microsoft article: http://support.microsoft.com/kb/324145
We use eventcreate.exe in our custom build process to log each step of the build in a custom page in the event log. You could use it to add event logging capability to your wisescripts.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
You can execute VB scipt in wise script and pass variables
You can embed VB scipt in wise script and pass variables within them by using setvariable and getvariable commands. Exit codes can be interchanged between VBS and its parent wise script.
I don't disagree with you
I don't disagree with you nac.
Exit codes can be inbterchanged between VBscript and parent wise script. Infact i can handle exit codes much better in vbscript as i specified initially in the tread.
My question here is how will you return an exit code to Altiris from within wise script. If you have a better way of doing this, please let us know. Thank you for your time.
Thanks,
Eshwar
Using kernel32.dll ExitProcess to pass Wise Script variable
Using kernel32.dll ExitProcess to pass Wise Script %INSTALL_RESULT% to Altiris
Using this process you can pass actual install results out.
If you would like the document please send me your email address and I'll send it.
kurtjeske@hotmail.com
Thanks. This has helped me as
Thanks. This has helped me as well.
Could some body suggest me
Could some body suggest me some good e-books for Wise Packaging
I have a suggestion
- First, learn that hijacking threads to post a new question - in any forum, not just here - isn't polite.
- Second, start with Phil Wilson's Definitive Guide to Windows Installer.
- Next, seek out John McFadyen's Windows Live blogs
- Others have found some of the pages at www.dawnstar.com.au/wpshelp/ helpful.
- Others still have found the little-known Google search engine to be of use.
Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.
Thread locked to prevent
Thread locked to prevent further hijacking by those who do not understand netiquette.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Would you like to reply?
Login or Register to post your comment.