cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dinesh_redhawk
Level 6

How to catch powershell errors in Installscript through LaunchAppandWait

Hello Friends,

I am trying to run a powershell script through LaunchAppandWait.
I want to catch the errors incase this powershell script fails.
But the problem is: the nResult = LAAW_PARAMETERS.nLaunchResult; always returns 0 even when the powershell script failed.

How to handle this case.
I have to fail the installer whenever this powershell script fails.
And i have to run this script through installscript only due to some dependency.

Any ideas?? Please help

Thanks
Labels (1)
0 Kudos
(2) Replies
rguggisberg
Level 13

nResult only tells you if the 'Launch' was successful.
You will need to use something else to detect pass/fail of the PS script.
One way to accomplish is to write a temporary value to the registry in PS and interrogate that in IS.
0 Kudos
Cary_R
Level 11

rguggisberg wrote:
nResult only tells you if the 'Launch' was successful.
You will need to use something else to detect pass/fail of the PS script.
One way to accomplish is to write a temporary value to the registry in PS and interrogate that in IS.


One could do it that way, if you're in control of the scripts. (You may not always have that option, and be forced to consume them verbatim for whatever reason)

The problem with Powershell is that you are going to want to parse the stderr stream from the process, which AFAIK you can't do from Installscript. I'd personally switch to a C# based custom action for launching the Powershell, because there's .Net classes for hosting Powershell scripts in managed code.

I haven't worked with it, but there may be some way of doing this as well with the native Powershell Custom Action support.
0 Kudos