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

Hi,

I search a way to look, using vb net, if a NT service still running on my
window server system.  The Vb code to look if the service is still on, will
be running on the same server.

I mean  dont need to look it over the network...

Its a little like this
: http://www.*-*-*.com/

but this is writen in C NET.

any have idea ? thanks



Sat, 30 Jul 2005 22:14:21 GMT  
 look if a nt service is runnning (window 2000 server), in vb net
Imports System.Management

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents ListView1 As System.Windows.Forms.ListView

<System.Diagnostics.De{*filter*}StepThrough()> Private Sub InitializeComponent()

Me.ListView1 = New System.Windows.Forms.ListView()

Me.SuspendLayout()

'

'ListView1

'

Me.ListView1.FullRowSelect = True

Me.ListView1.GridLines = True

Me.ListView1.Name = "ListView1"

Me.ListView1.Size = New System.Drawing.Size(928, 456)

Me.ListView1.TabIndex = 0

Me.ListView1.View = System.Windows.Forms.View.Details

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(928, 454)

Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListView1})

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim wmi As ManagementObjectSearcher = New ManagementObjectSearcher("Select *
from WIN32_SERVICE")

Dim moc As ManagementObjectCollection = wmi.Get()

Dim moo As ManagementObject

Dim pdc As PropertyDataCollection

Dim pd As PropertyData

For Each moo In moc

For Each pd In moo.Properties

Call ListView1.Columns.Add(pd.Name.ToString(), 120,
HorizontalAlignment.Left)

Next

Exit For

Next

Dim wmi1 As ManagementObjectSearcher = New ManagementObjectSearcher("Select
* from WIN32_SERVICE")

Dim moc1 As ManagementObjectCollection = wmi1.Get()

Dim moo1 As ManagementObject

Dim pdc1 As PropertyDataCollection

Dim pd1 As PropertyData

For Each moo1 In moc1

Dim li As ListViewItem

Dim V As Integer

V = 0

For Each pd1 In moo1.Properties

If V = 0 Then

If IsNothing(pd1.Value) = True Then

li = ListView1.Items.Add("")

Else

li = ListView1.Items.Add(pd1.Value.ToString())

End If

V = V + 1

Else

If IsNothing(pd1.Value) = True Then

li.SubItems.Add("")

Else

li.SubItems.Add(pd1.Value.ToString())

End If

End If

Next

V = 0

Next

End Sub

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

End Sub

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize

ListView1.Width = Me.Width - 10

ListView1.Height = Me.Height - 35

End Sub

End Class

hth

r.t.edwards

http://www.*-*-*.com/


Quote:
> Hi,

> I search a way to look, using vb net, if a NT service still running on my
> window server system.  The Vb code to look if the service is still on,
will
> be running on the same server.

> I mean  dont need to look it over the network...

> Its a little like this
> : http://www.*-*-*.com/

> but this is writen in C NET.

> any have idea ? thanks



Sat, 30 Jul 2005 23:33:08 GMT  
 look if a nt service is runnning (window 2000 server), in vb net
I will be more specific.

What I need to know is if a NT window 2000 service  (background services of
NT) on my server, named like "Norton AntiVirus Client", is still running?

I your code, I think you only check process runing by the application only.

right?



Quote:
> Imports System.Management

> Public Class Form1

> Inherits System.Windows.Forms.Form

> #Region " Windows Form Designer generated code "

> Public Sub New()

> MyBase.New()

> 'This call is required by the Windows Form Designer.

> InitializeComponent()

> 'Add any initialization after the InitializeComponent() call

> End Sub

> 'Form overrides dispose to clean up the component list.

> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

> If disposing Then

> If Not (components Is Nothing) Then

> components.Dispose()

> End If

> End If

> MyBase.Dispose(disposing)

> End Sub

> 'Required by the Windows Form Designer

> Private components As System.ComponentModel.IContainer

> 'NOTE: The following procedure is required by the Windows Form Designer

> 'It can be modified using the Windows Form Designer.

> 'Do not modify it using the code editor.

> Friend WithEvents ListView1 As System.Windows.Forms.ListView

> <System.Diagnostics.De{*filter*}StepThrough()> Private Sub

InitializeComponent()

- Show quoted text -

Quote:

> Me.ListView1 = New System.Windows.Forms.ListView()

> Me.SuspendLayout()

> '

> 'ListView1

> '

> Me.ListView1.FullRowSelect = True

> Me.ListView1.GridLines = True

> Me.ListView1.Name = "ListView1"

> Me.ListView1.Size = New System.Drawing.Size(928, 456)

> Me.ListView1.TabIndex = 0

> Me.ListView1.View = System.Windows.Forms.View.Details

> '

> 'Form1

> '

> Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

> Me.ClientSize = New System.Drawing.Size(928, 454)

> Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListView1})

> Me.Name = "Form1"

> Me.Text = "Form1"

> Me.ResumeLayout(False)

> End Sub

> #End Region

> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load

> Dim wmi As ManagementObjectSearcher = New ManagementObjectSearcher("Select
*
> from WIN32_SERVICE")

> Dim moc As ManagementObjectCollection = wmi.Get()

> Dim moo As ManagementObject

> Dim pdc As PropertyDataCollection

> Dim pd As PropertyData

> For Each moo In moc

> For Each pd In moo.Properties

> Call ListView1.Columns.Add(pd.Name.ToString(), 120,
> HorizontalAlignment.Left)

> Next

> Exit For

> Next

> Dim wmi1 As ManagementObjectSearcher = New

ManagementObjectSearcher("Select

- Show quoted text -

Quote:
> * from WIN32_SERVICE")

> Dim moc1 As ManagementObjectCollection = wmi1.Get()

> Dim moo1 As ManagementObject

> Dim pdc1 As PropertyDataCollection

> Dim pd1 As PropertyData

> For Each moo1 In moc1

> Dim li As ListViewItem

> Dim V As Integer

> V = 0

> For Each pd1 In moo1.Properties

> If V = 0 Then

> If IsNothing(pd1.Value) = True Then

> li = ListView1.Items.Add("")

> Else

> li = ListView1.Items.Add(pd1.Value.ToString())

> End If

> V = V + 1

> Else

> If IsNothing(pd1.Value) = True Then

> li.SubItems.Add("")

> Else

> li.SubItems.Add(pd1.Value.ToString())

> End If

> End If

> Next

> V = 0

> Next

> End Sub

> Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

> End Sub

> Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Resize

> ListView1.Width = Me.Width - 10

> ListView1.Height = Me.Height - 35

> End Sub

> End Class

> hth

> r.t.edwards

> http://www.*-*-*.com/



> > Hi,

> > I search a way to look, using vb net, if a NT service still running on
my
> > window server system.  The Vb code to look if the service is still on,
> will
> > be running on the same server.

> > I mean  dont need to look it over the network...

> > Its a little like this
> > : http://www.*-*-*.com/

> > but this is writen in C NET.

> > any have idea ? thanks



Sat, 30 Jul 2005 23:52:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. NT/2000 Service in VB.NET

2. Looking for freeware ocx to access Parallel port from VB on Windows 2000 or NT

3. VB.Net installation on Windows 2000 Server

4. rds windows nt vs windows 2000 server

5. How to make a Windows nt/2000 Services in Visual Basic 6

6. VBEE app as service in Windows 2000 server?

7. installing vb program in Windows NT, Windows 2000

8. NT Service: An OLE Control for Creating Windows NT Services in Visual Basic (MSDN article)

9. NT Service: An OLE Control for Creating Windows NT Services in Visual Basic (MSDN article)

10. NT Service: An OLE Control for Creating Windows NT Services in Visual Basic (MSDN article)

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

12. How to control NT/2000 service from VB?

 

 
Powered by phpBB® Forum Software