The aim of the question is to stop an installshield installation once it has started installing the service.
In particular, I want to stop the installation if a file file.txt is not found in the selected directory (the user will select the installation path).
To control that, I'm calling the BeforeInstall
event from ServiceInstaller
.
Private Sub ServiceInstaller1_BeforeInstall(sender As Object, e As InstallEventArgs) Handles ServiceInstaller1.BeforeInstall
Dim filePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).Replace("\", "\\")
If Not File.Exists(filePath) & "\file.txt" Then
MsgBox("The specified file is not found in that path, the installation will stop.")
'Missing code
End If
End Sub
I have tried with End
, Exit
, and many others but no one stops the installation.
Clearly you can show the not found file likely by a
Dialog
and call theRoleBack
method which rolls back service application information written to the registry by the installation procedure. This method is meant to be used by installation tools, which process the appropriate methods automatically. (OverridesInstaller.Rollback(IDictionary)
).To be aware of
ServiceInstaller
methods see The MSDN. And for usingRollBack
method, See This MSDN Documentation which remarks :