Restart And Hide Command Windows

Topics: Updater Application Block
Apr 7, 2006 at 3:22 AM
originally posted by: Deathpig

Ive seen an explanation of this but it was in C# and Im having problems following along with it. Is there any place where i can look at an example of a custom WaitForExitProcessor that hides the command window and restarts the app automatically?

Thanks in advance
Apr 7, 2006 at 10:14 AM
originally posted by: Apocwhen

In the ActivationProcessors Project, Modify the WaitForApplicationExitProcessor.vb file at line 173:

Dim psi As New ProcessStartInfo("wait.bat")
psi.WindowStyle = ProcessWindowStyle.Hidden

this should hide the command window.

To restart the application using the InProcess method, first the User must exit the application, or if this is the part you intend doing automatically then you can close the application on the user once the Updaters ActivationInitializationAborted is fired.

I'm not sure if the UAB has it's own way or restarting the application but the Manifest includes an xml element to specify the entrypoint and parameters for your application so you could create your own ActivationProcessor and add it to the end of the tasks list in your manifest file.
This is the following ActivationProcessor I use (converted from c#). This will use the entrypoint and parameters specified from the manifest to restart the application. Make sure to include it in the tasks list of the manifest file to be executed.
task type="MyNamespace.FileExecuteProcessor, MyProjectOutputName" name="FileExecuteProcessor" /

Imports Microsoft.ApplicationBlocks.Updater

Public Class FileExecuteProcessor
Inherits IActivationProcessor
Dim task As UpdaterTask

Public Sub New()
' TODO: Add constructor logic here
End Sub

#Region "IActivationProcessor Members"

Public Sub PrepareExecution()
' TODO: Add FileExecuteProcessor.PrepareExecution implementation
End Sub

Public Sub Execute()
'Restart Application Using Manifest Entry Point
System.Diagnostics.Process.Start(task.Manifest.Application.StartCommand, task.Manifest.Application.StartParameters)
End Sub

Public Sub Init(ByVal data As Microsoft.ApplicationBlocks.Updater.Configuration.ActivationProcessorProviderData, ByVal task As UpdaterTask)
Me.task = task
End Sub

Public Sub OnError()
' TODO: Add FileExecuteProcessor.OnError implementation
End Sub

#End Region

End Class