MSI to install and start a service

  • Thread starter Thread starter Russ Green
  • Start date Start date
R

Russ Green

I'm using a Setup Project in VB.NET 2003 Standard to install a windows
service application. I would like this installer to start the service after
install. How do I do that?

Thanks,
Russ
 
See the MSDN Topic "Walkthrough: Creating a Windows Service Application in the
Component Designer". Maybe you already did, but that refers to a custom action
that installs your service. In the Install method (override it) use
ServiceController to start it.

(If your company happens to use a commercial tool from InstallShield, Wise etc
etc, you don't need any of the above. They create the right entries in the MSI
file, ServiceInstall and ServiceControl tables, that get the Windows Installer
to do literally all of that stuff without you needing to write code).
 
Thanks for your answers guys. Did it with the following code in
ProjectInstaller.vb

Protected Overrides Sub OnAfterInstall(ByVal savedState As IDictionary)

MyBase.OnAfterInstall(savedState)

Try

Microsoft.VisualBasic.Shell("net start IpNotifyService")

Catch ex As Exception

End Try

End Sub 'OnAfterInstall



Phil Wilson said:
See the MSDN Topic "Walkthrough: Creating a Windows Service Application in the
Component Designer". Maybe you already did, but that refers to a custom action
that installs your service. In the Install method (override it) use
ServiceController to start it.

(If your company happens to use a commercial tool from InstallShield, Wise etc
etc, you don't need any of the above. They create the right entries in the MSI
file, ServiceInstall and ServiceControl tables, that get the Windows Installer
to do literally all of that stuff without you needing to write code).
--
Phil Wilson [MVP Windows Installer]
----
Russ Green said:
I'm using a Setup Project in VB.NET 2003 Standard to install a windows
service application. I would like this installer to start the service after
install. How do I do that?

Thanks,
Russ
 
Is there a reason why you decided not to use the ServiceController class?

konst

Russ Green said:
Thanks for your answers guys. Did it with the following code in
ProjectInstaller.vb

Protected Overrides Sub OnAfterInstall(ByVal savedState As IDictionary)

MyBase.OnAfterInstall(savedState)

Try

Microsoft.VisualBasic.Shell("net start IpNotifyService")

Catch ex As Exception

End Try

End Sub 'OnAfterInstall



Phil Wilson said:
See the MSDN Topic "Walkthrough: Creating a Windows Service Application
in
the
Component Designer". Maybe you already did, but that refers to a custom action
that installs your service. In the Install method (override it) use
ServiceController to start it.

(If your company happens to use a commercial tool from InstallShield,
Wise
etc
etc, you don't need any of the above. They create the right entries in
the
MSI
file, ServiceInstall and ServiceControl tables, that get the Windows Installer
to do literally all of that stuff without you needing to write code).
--
Phil Wilson [MVP Windows Installer]
----
Russ Green said:
I'm using a Setup Project in VB.NET 2003 Standard to install a windows
service application. I would like this installer to start the service after
install. How do I do that?

Thanks,
Russ
 
Is there a reason why you decided not to use the ServiceController class?

konst

Russ Green said:
Thanks for your answers guys. Did it with the following code in
ProjectInstaller.vb

Protected Overrides Sub OnAfterInstall(ByVal savedState As IDictionary)

MyBase.OnAfterInstall(savedState)

Try

Microsoft.VisualBasic.Shell("net start IpNotifyService")

Catch ex As Exception

End Try

End Sub 'OnAfterInstall



Phil Wilson said:
See the MSDN Topic "Walkthrough: Creating a Windows Service Application
in
the
Component Designer". Maybe you already did, but that refers to a custom action
that installs your service. In the Install method (override it) use
ServiceController to start it.

(If your company happens to use a commercial tool from InstallShield,
Wise
etc
etc, you don't need any of the above. They create the right entries in
the
MSI
file, ServiceInstall and ServiceControl tables, that get the Windows Installer
to do literally all of that stuff without you needing to write code).
--
Phil Wilson [MVP Windows Installer]
----
Russ Green said:
I'm using a Setup Project in VB.NET 2003 Standard to install a windows
service application. I would like this installer to start the service after
install. How do I do that?

Thanks,
Russ
 
Interesting - I wonder if there's a command prompt screen popping up?
--
Phil Wilson [MVP Windows Installer]
----
konsu said:
Is there a reason why you decided not to use the ServiceController class?

konst

Russ Green said:
Thanks for your answers guys. Did it with the following code in
ProjectInstaller.vb

Protected Overrides Sub OnAfterInstall(ByVal savedState As IDictionary)

MyBase.OnAfterInstall(savedState)

Try

Microsoft.VisualBasic.Shell("net start IpNotifyService")

Catch ex As Exception

End Try

End Sub 'OnAfterInstall



Phil Wilson said:
See the MSDN Topic "Walkthrough: Creating a Windows Service Application
in
the
Component Designer". Maybe you already did, but that refers to a custom action
that installs your service. In the Install method (override it) use
ServiceController to start it.

(If your company happens to use a commercial tool from InstallShield,
Wise
etc
etc, you don't need any of the above. They create the right entries in
the
MSI
file, ServiceInstall and ServiceControl tables, that get the Windows Installer
to do literally all of that stuff without you needing to write code).
--
Phil Wilson [MVP Windows Installer]
----
I'm using a Setup Project in VB.NET 2003 Standard to install a windows
service application. I would like this installer to start the service after
install. How do I do that?

Thanks,
Russ
 
Yes, a command prompt screen does popup.

Russ

Phil Wilson said:
Interesting - I wonder if there's a command prompt screen popping up?
--
Phil Wilson [MVP Windows Installer]
----
konsu said:
Is there a reason why you decided not to use the ServiceController class?

konst

Russ Green said:
Thanks for your answers guys. Did it with the following code in
ProjectInstaller.vb

Protected Overrides Sub OnAfterInstall(ByVal savedState As IDictionary)

MyBase.OnAfterInstall(savedState)

Try

Microsoft.VisualBasic.Shell("net start IpNotifyService")

Catch ex As Exception

End Try

End Sub 'OnAfterInstall



See the MSDN Topic "Walkthrough: Creating a Windows Service
Application
in
the
Component Designer". Maybe you already did, but that refers to a custom
action
that installs your service. In the Install method (override it) use
ServiceController to start it.

(If your company happens to use a commercial tool from
InstallShield,
Wise
etc
etc, you don't need any of the above. They create the right entries
in
the
MSI
file, ServiceInstall and ServiceControl tables, that get the Windows
Installer
to do literally all of that stuff without you needing to write code).
--
Phil Wilson [MVP Windows Installer]
----
I'm using a Setup Project in VB.NET 2003 Standard to install a windows
service application. I would like this installer to start the service
after
install. How do I do that?

Thanks,
Russ
 
Back
Top