How do I kill a windows service using VB.Net? 
Author Message
 How do I kill a windows service using VB.Net?

Does anyone have an example of killing a windows service in VB.Net  I know
that there is the Process.Kill, but I haven't been able to get it to work.


Mon, 02 May 2005 06:10:16 GMT  
 How do I kill a windows service using VB.Net?
David,

this is definitly not a beautiful solution, however, it works.

It is possible to stop/start local NT/2000 services using the
DosBox-based commands "NET STOP" and "NET START".
From VB, it should be possible to stop a service using the
"Shell" command - something like this:

Shell "NET STOP servicename"

HTH.

Bye
Ralf

Quote:

> Does anyone have an example of killing a windows service in VB.Net  I know
> that there is the Process.Kill, but I haven't been able to get it to work.



Wed, 04 May 2005 03:42:21 GMT  
 How do I kill a windows service using VB.Net?


Quote:
> David,

> this is definitly not a beautiful solution, however, it works.

> It is possible to stop/start local NT/2000 services using the
> DosBox-based commands "NET STOP" and "NET START".
> From VB, it should be possible to stop a service using the
> "Shell" command - something like this:

> Shell "NET STOP servicename"

> HTH.

> Bye
> Ralf


> > Does anyone have an example of killing a windows service in VB.Net  I
know
> > that there is the Process.Kill, but I haven't been able to get it to

work.

Or in VB.NET:

Option Explicit On
Option Strict On

Imports System.ServiceProcess
Imports System.ComponentModel
Imports System.Windows.Forms

Module App

    Public Sub Main()
        Dim sc As New ServiceController("MyService")

        Try
            sc.Stop()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            sc.Close()
        End Try
    End Sub

End Module

HTH,
Tom Shelton



Wed, 04 May 2005 14:20:07 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help Urgently Needed: Example on killing a windows service using VB.Net

2. windows service using VB.NET

3. Windows Service in VB.NET - Failed to process service command

4. Window Service upgrade to VB.Net 2003

5. Windows Service in VB.NET

6. look if a nt service is runnning (window 2000 server), in vb net

7. Windows Services in VB.net

8. Installing VB.NET Windows Service on different machine.

9. Problem with windows service in vb.net

10. deploying windows service application (vb.net)

11. Self-Installing VB.NET Windows Service

12. windows service. vb.net

 

 
Powered by phpBB® Forum Software