Running a VBScript as a deferred action. I want it (based on some condition checking by the vbscript) to fail and terminate the installation. How do I go about doing this?

Also, I was wondering if there is a way to write a "custom" line manually into the log file.. possibly using a session object within a vbscript?
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
#1 then vbscript function return value will handle this, ex.
Function MyFunction()
Const msiDoActionStatusSuccess = 1
Const msiDoActionStatusFailure = 3

If Something_Is_Wrong Then
MyFunction = msiDoActionStatusFailure : Exit Function
End If

MyFunction = msiDoActionStatusSuccess
End Function

#2 Something like this:
msiLog "text that should be logged"

Function msiLog(Message)
Const msiMessageTypeInfo = &H04000000

Dim Record : Set Record = Nothing
Set Record = Session.Installer.CreateRecord(1)

Record.StringData(0) = "CA Log: [1]"
Record.StringData(1) = Message

Session.Message msiMessageTypeInfo, Record
Set Record = Nothing
End Function
Answered 02/11/2009 by: AngelD
Red Belt

Please log in to comment
0
Hi AngelD, Thanks for the response.

I'm not quite following your first answer. Is MyFunction the name of my Custom Action?

Here's what I'm trying to do. This is the VBS inside a CA called "MyCustomAction"

'Dostuff to figure determine if Something_Is_Wrong
If Something_Is_Wrong
'tell Windows Installer that the CA MyCustomAction failed
End If
Answered 02/11/2009 by: jayteeo
Purple Belt

Please log in to comment
0
You can specify a specific function to call withing the vbscript custom action, in my example that would be the MyFunction function.
If this function returns value 3 the installation will fail
The "if statement" you need to come up with yourself when you want to catch your function to return a failure.
Answered 02/11/2009 by: AngelD
Red Belt

Please log in to comment
0
One of the first habits you need to get into is using names which mean something for your CAs, functions, variables and so on. Calling it 'MyCustomAction' means that whoever has to maintain your package at some future point has no clue what it does until he/she opens it to look. Calling it (say) 'TestPresenceOfBlah.EXE' shows its function straight away.

For details on how CAs work, have a read of the 'Custom Action' section on MSDN.
Answered 02/12/2009 by: VBScab
Red Belt

Please log in to comment
0
I'm very much aware of defining functions and subroutines within the script, which is what I'm already doing. I had overlooked a couple of the lines in your example which caused me some confusion. Let me give that a shot.
Answered 02/12/2009 by: jayteeo
Purple Belt

Please log in to comment
0
Hi AngelD - Your suggestion didn't seem to work unless I've overlooked something.
This is my CA's embedded script..

***
Function Install_IIS_7()
Const msiDoActionStatusSuccess = 1
Const msiDoActionStatusFailure = 3
'Create Shell Object
'Set Style Property
Dim WindowStyle
WindowStyle = 0 '0 for hidden, 4 to show it

'Set Variables
Dim Executable, Parameters, Path, TempFolder
Executable = "ServerManagerCmd.exe"
Parameters = "-install Web-Server"

TempFolder = Session.Property("CustomActionData")
'Run installation
Set WshShell = CreateObject("WScript.Shell")
ExitCode = WshShell.Run("cmd.exe /c %WinDir%\SysNative\" & Executable & " " & _
Parameters & "> " & TempFolder & "InstallIIS7.txt" , _
WindowStyle, True)

'Delete Temporary file
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(TempFolder & "InstallIIS7.txt") _
And ExitCode = 0 Then
FSO.DeleteFile(TempFolder & "InstallIIS7.txt")
End If
MsgBox("Exit Code: " & ExitCode)
If ExitCode <> 0 Then
Install_IIS_7 = msiDoActionStatusFailure
Else
Install_IIS_7 = msiDoActionStatusSuccess
End If

Set WshShell = Nothing
Set FSO = Nothing
End Function
Install_IIS_7()

****

When ExitCode = 1001, the CA does not fail. What am I missing?
Answered 02/12/2009 by: jayteeo
Purple Belt

Please log in to comment
0
thanks, I got it to work by changing the CA to call vbscript for installation (vs. embedded code).
Answered 02/12/2009 by: jayteeo
Purple Belt

Please log in to comment
0
Thanks AngelD the loggingn worked perfectly
Answered 02/12/2009 by: jayteeo
Purple Belt

Please log in to comment
0
Great work jayteeo!
Answered 02/12/2009 by: AngelD
Red Belt

Please log in to comment
0
good for you, told you embedded code sux. :-)
Answered 02/12/2009 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
You did? I probably ignored you. : D
Answered 02/12/2009 by: jayteeo
Purple Belt

Please log in to comment
0
ORIGINAL: jayteeo

You did? I probably ignored you. : D

Next time maybe you shouldn't [;)]
Answered 02/12/2009 by: AngelD
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity