/build/static/layout/Breadcrumb_cap_w.png

Force Installation Script to Stop?

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

Answers (12)

Posted by: AngelD 15 years ago
Red Belt
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
Posted by: jayteeo 15 years ago
Purple Belt
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
Posted by: AngelD 15 years ago
Red Belt
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.
Posted by: anonymous_9363 15 years ago
Red Belt
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.
Posted by: jayteeo 15 years ago
Purple Belt
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.
Posted by: jayteeo 15 years ago
Purple Belt
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?
Posted by: jayteeo 15 years ago
Purple Belt
0
thanks, I got it to work by changing the CA to call vbscript for installation (vs. embedded code).
Posted by: jayteeo 15 years ago
Purple Belt
0
Thanks AngelD the loggingn worked perfectly
Posted by: AngelD 15 years ago
Red Belt
0
Great work jayteeo!
Posted by: aogilmor 15 years ago
9th Degree Black Belt
0
good for you, told you embedded code sux. :-)
Posted by: jayteeo 15 years ago
Purple Belt
0
You did? I probably ignored you. : D
Posted by: AngelD 15 years ago
Red Belt
0
ORIGINAL: jayteeo

You did? I probably ignored you. : D

Next time maybe you shouldn't [;)]
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ