473,699 Members | 3,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check if a Windows service running

What would be a good way to check programmaticall y whether a service was
running?

We have a service that dies periodically and I need to check to see if this
service is running. I know how to check to see if the status is in stopped
or running mode. But that doesn't tell me if it is actually running.

I need to know this so that if it happens I can programmaticall y start the
same service on another machine.

What I would like to do is build a service that just periodically checks
(about once a minute) to see if the other service is actually running.

Thanks,

Tom
Aug 9 '06 #1
4 4178
Hi,

I think u may take help of System.Diagnost ics.Process class.

GetProcesses() method returns all running processes.

So why dont u compare your process with the running processes.

Regards,
Bharathi Kumar.

tshad wrote:
What would be a good way to check programmaticall y whether a service was
running?

We have a service that dies periodically and I need to check to see if this
service is running. I know how to check to see if the status is in stopped
or running mode. But that doesn't tell me if it is actually running.

I need to know this so that if it happens I can programmaticall y start the
same service on another machine.

What I would like to do is build a service that just periodically checks
(about once a minute) to see if the other service is actually running.

Thanks,

Tom
Aug 9 '06 #2
"Bharathi kumar" <bh************ @gmail.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Hi,

I think u may take help of System.Diagnost ics.Process class.

GetProcesses() method returns all running processes.

So why dont u compare your process with the running processes.
Won't GetProcesses() show it as running if the Services window shows it as
running? I assume that the Services Window calls this routine (could be
wrong here).

But I have a service that sends out emails that shows in running mode and
for some reason it dies once every 5 or 6 days and seems to be frozen (could
be in an infinite loop - but I can't find where that would happen). The
status in the services windows or when I request it from another program
shows it as running (which would make sense if it never hit the Stop code).

I need to find a good way to monitor it to tell if it has stopped or not
(until I can find the problem with the code).

BTW, when I get to this point, I can't stop the program at all. I need to
reboot the server to get it released.

Thanks,

Tom
>
Regards,
Bharathi Kumar.

tshad wrote:
>What would be a good way to check programmaticall y whether a service was
running?

We have a service that dies periodically and I need to check to see if
this
service is running. I know how to check to see if the status is in
stopped
or running mode. But that doesn't tell me if it is actually running.

I need to know this so that if it happens I can programmaticall y start
the
same service on another machine.

What I would like to do is build a service that just periodically checks
(about once a minute) to see if the other service is actually running.

Thanks,

Tom

Aug 9 '06 #3
I've made once a small application (with Visual Studio 2005 Beta 1) that
controlled a service: It showed the status and allowed the user to change
the status etc.

I don't know if it's this what you are looking for:

'** THE frmController.v b-file
Option Explicit On

Imports System.ServiceP rocess

Imports System.Configur ation

Imports VbPowerPack

Imports Microsoft.Win32

Imports System.IO

Public Class frmController

Private m_svc As ServiceControll er

Private strMyService As String

Private WithEvents tmrRefresh As New Timers.Timer

Private Sub frmController_L oad(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

FillValues()

tmrRefresh.Inte rval = 5000

tmrRefresh.Star t()

End Sub

Private Sub FillValues()

'Service

strMyService = ConfigurationSe ttings.AppSetti ngs.Get("MyServ ice")

lblService.Text = strMyService

'Software

'ConfigurationS ettings.AppSett ings.Get("MySer vicePath")

If File.Exists(Con figurationSetti ngs.AppSettings .Get("MyService Path")) Then

lblSoftware.Tex t = "Available"

pnlSoftware.Ble nd = New BlendFill(Blend Style.BackwardD iagonal, Color.Green,
Color.White)

Else

lblSoftware.Tex t = "Not Available"

pnlSoftware.Ble nd = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

End If

'Installed

EvaluateInstall ed()

End Sub

Private Sub EvaluateInstall ed()

If IsInstalled() Then

'installed

lblInstalled.Te xt = "Installed"

btnInstall.Text = "Uninstall"

pnlInstalled.Bl end = New BlendFill(Blend Style.BackwardD iagonal, Color.Green,
Color.White)

'StartupType

EvaluateStartup Type()

'Status

EvaluateStatus( )

Else

'installed

lblInstalled.Te xt = "Not Available"

btnInstall.Text = "Install"

pnlInstalled.Bl end = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

'startup type

lblStartupType. Text = "Disabled"

pnlStartupType. Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

'status

lblStatus.Text = "Stopped"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

End If

End Sub

Private Function IsInstalled() As Boolean

'strMyService = ConfigurationSe ttings.AppSetti ngs.Get("MyServ ice")

IsInstalled = False

Dim installedServic es() As ServiceControll er

Dim tempService As ServiceControll er

installedServic es = ServiceControll er.GetServices

For Each tempService In installedServic es

If UCase(tempServi ce.ServiceName) = UCase(strMyServ ice) Then

'blnIsServiceIn stalled = true

m_svc = tempService

IsInstalled = True

End If

Next

End Function

Private Property ServiceStartupT ype() As ServiceStartMod e

Get

Dim RegValue As ServiceStartMod e

Dim RegKey As RegistryKey

RegKey =
Registry.LocalM achine.OpenSubK ey("SYSTEM\\Cur rentControlSet\ \Services\\" &
strMyService)

If Not (RegKey Is Nothing) Then

RegValue = CType(RegKey.Ge tValue("Start") , ServiceStartMod e)

RegKey.Close()

RegKey = Nothing

Return RegValue

Else

Return ServiceStartMod e.Disabled

End If

End Get

Set(ByVal value As ServiceStartMod e)

Dim RegKey As RegistryKey

RegKey =
Registry.LocalM achine.OpenSubK ey("SYSTEM\\Cur rentControlSet\ \Services\\" &
strMyService, True)

If Not (RegKey Is Nothing) Then

RegKey.SetValue ("Start", CType(value, Integer))

RegKey.Close()

RegKey = Nothing

Else

MessageBox.Show ("Cannot modify the Startup type.", "Startup Type",
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

End If

End Set

End Property

Private Sub EvaluateStartup Type()

'Startup Type

Select Case ServiceStartupT ype

Case ServiceStartMod e.Automatic

lblStartupType. Text = "Automatic"

pnlStartupType. Blend = New BlendFill(Blend Style.BackwardD iagonal,
Color.Green, Color.White)

Case ServiceStartMod e.Manual

lblStartupType. Text = "Manual"

pnlStartupType. Blend = New BlendFill(Blend Style.BackwardD iagonal,
Color.Orange, Color.White)

Case Else

lblStartupType. Text = "Disabled"

pnlStartupType. Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

End Select

End Sub

Private Sub EvaluateStatus( )

'Status

Select Case m_svc.Status

Case ServiceControll erStatus.Contin uePending

lblStatus.Text = "Continue Pending"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Green,
Color.White)

Case ServiceControll erStatus.Paused

lblStatus.Text = "Paused"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Orange,
Color.White)

Case ServiceControll erStatus.PauseP ending

lblStatus.Text = "Pause Pending"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Orange,
Color.White)

Case ServiceControll erStatus.Runnin g

lblStatus.Text = "Started"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Green,
Color.White)

Case ServiceControll erStatus.StartP ending

lblStatus.Text = "Start Pending"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Green,
Color.White)

Case ServiceControll erStatus.StopPe nding

lblStatus.Text = "Stop Pending"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

Case Else

lblStatus.Text = "Stopped"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

End Select

End Sub

Private Sub btnStartupType_ Click(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnStartupType. Click

Select Case ServiceStartupT ype

Case ServiceStartMod e.Automatic

ServiceStartupT ype = ServiceStartMod e.Manual

Case ServiceStartMod e.Manual

ServiceStartupT ype = ServiceStartMod e.Disabled

Case Else

ServiceStartupT ype = ServiceStartMod e.Automatic

End Select

EvaluateStartup Type()

End Sub

Private Sub tmrRefresh_Elap sed(ByVal sender As Object, ByVal e As
System.Timers.E lapsedEventArgs ) Handles tmrRefresh.Elap sed

FillValues()

End Sub

Private Sub btnStart_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnStart.Click

Try

m_svc.Start()

EvaluateStatus( )

Catch ex As Exception

MessageBox.Show ("Excepction occured while Starting Service", "Service
Controller", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

End Try

End Sub

Private Sub btnStop_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnStop.Click

Try

m_svc.Stop()

EvaluateStatus( )

Catch ex As Exception

MessageBox.Show ("Excepction occured while Stopping Service", "Service
Controller", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

End Try

End Sub

Private Sub btnPauze_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnPauze.Click

Try

m_svc.Pause()

EvaluateStatus( )

Catch ex As Exception

MessageBox.Show ("Excepction occured while Pausing Service", "Service
Controller", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

End Try

End Sub

Public Overloads Sub RunExe(ByVal strName As String, ByVal strArg As String)

Dim prcLogin As New Process

prcLogin.StartI nfo.UseShellExe cute = True

prcLogin.StartI nfo.RedirectSta ndardOutput = False

prcLogin.StartI nfo.FileName = strName

prcLogin.StartI nfo.Arguments = strArg

prcLogin.Start( )

prcLogin.Close( )

End Sub

Private Sub btnInstall_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnInstall.Clic k

Dim sArgs As String

If btnInstall.Text = "Install" Then

sArgs = " /name=""" & lblService.Text & """ """ &
ConfigurationSe ttings.AppSetti ngs.Get("MyServ icePath") & """"

RunExe(Configur ationSettings.A ppSettings.Get( "InstallUti l"), sArgs)

Else

sArgs = " /U /name=""" & lblService.Text & """ """ &
ConfigurationSe ttings.AppSetti ngs.Get("MyServ icePath") & """"

RunExe(Configur ationSettings.A ppSettings.Get( "InstallUti l"), sArgs)

End If

EvaluateInstall ed()

End Sub

End Class


'*** THE frmController.D esigner.vb-file**

Partial Public Class frmController

Inherits System.Windows. Forms.Form

<System.Diagnos tics.DebuggerNo nUserCode()_

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeCompo nent()

End Sub

'Form overrides dispose to clean up the component list.

<System.Diagnos tics.DebuggerNo nUserCode()_

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Disp ose()

End If

MyBase.Dispose( disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.Componen tModel.IContain er

'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.

<System.Diagnos tics.DebuggerSt epThrough()_

Private Sub InitializeCompo nent()

Dim resources As System.Componen tModel.Componen tResourceManage r = New
System.Componen tModel.Componen tResourceManage r(GetType(frmCo ntroller))

Me.Label1 = New System.Windows. Forms.Label

Me.Label2 = New System.Windows. Forms.Label

Me.Label3 = New System.Windows. Forms.Label

Me.Label4 = New System.Windows. Forms.Label

Me.lblSoftware = New System.Windows. Forms.Label

Me.lblInstalled = New System.Windows. Forms.Label

Me.pnlStatus = New VbPowerPack.Ble ndPanel

Me.lblStatus = New System.Windows. Forms.Label

Me.lblStartupTy pe = New System.Windows. Forms.Label

Me.Label5 = New System.Windows. Forms.Label

Me.lblService = New System.Windows. Forms.Label

Me.pnlStartupTy pe = New VbPowerPack.Ble ndPanel

Me.pnlInstalled = New VbPowerPack.Ble ndPanel

Me.pnlSoftware = New VbPowerPack.Ble ndPanel

Me.btnStartupTy pe = New System.Windows. Forms.Button

Me.btnStart = New System.Windows. Forms.Button

Me.btnStop = New System.Windows. Forms.Button

Me.btnPauze = New System.Windows. Forms.Button

Me.btnInstall = New System.Windows. Forms.Button

Me.pnlStatus.Su spendLayout()

Me.pnlStartupTy pe.SuspendLayou t()

Me.pnlInstalled .SuspendLayout( )

Me.pnlSoftware. SuspendLayout()

Me.SuspendLayou t()

'

'Label1

'

Me.Label1.AutoS ize = True

Me.Label1.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label1.Locat ion = New System.Drawing. Point(44, 77)

Me.Label1.Name = "Label1"

Me.Label1.Size = New System.Drawing. Size(78, 17)

Me.Label1.TabIn dex = 2

Me.Label1.Text = "Applicatio n :"

'

'Label2

'

Me.Label2.AutoS ize = True

Me.Label2.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label2.Locat ion = New System.Drawing. Point(44, 127)

Me.Label2.Margi n = New System.Windows. Forms.Padding(3 , 3, 3, 1)

Me.Label2.Name = "Label2"

Me.Label2.Size = New System.Drawing. Size(62, 17)

Me.Label2.TabIn dex = 3

Me.Label2.Text = "Installed :"

'

'Label3

'

Me.Label3.AutoS ize = True

Me.Label3.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label3.Locat ion = New System.Drawing. Point(44, 177)

Me.Label3.Margi n = New System.Windows. Forms.Padding(3 , 1, 3, 3)

Me.Label3.Name = "Label3"

Me.Label3.Size = New System.Drawing. Size(89, 17)

Me.Label3.TabIn dex = 4

Me.Label3.Text = "Startup Type :"

'

'Label4

'

Me.Label4.AutoS ize = True

Me.Label4.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label4.Locat ion = New System.Drawing. Point(44, 227)

Me.Label4.Name = "Label4"

Me.Label4.Size = New System.Drawing. Size(50, 17)

Me.Label4.TabIn dex = 5

Me.Label4.Text = "Status :"

'

'lblSoftware

'

Me.lblSoftware. AutoSize = True

Me.lblSoftware. BackColor = System.Drawing. Color.Transpare nt

Me.lblSoftware. Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.lblSoftware. Location = New System.Drawing. Point(4, 3)

Me.lblSoftware. Name = "lblSoftwar e"

Me.lblSoftware. Size = New System.Drawing. Size(84, 17)

Me.lblSoftware. TabIndex = 0

Me.lblSoftware. Text = "Not Available"

'

'lblInstalled

'

Me.lblInstalled .AutoSize = True

Me.lblInstalled .BackColor = System.Drawing. Color.Transpare nt

Me.lblInstalled .Font = New System.Drawing. Font("Microsoft Sans Serif",
9.75!, System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.lblInstalled .Location = New System.Drawing. Point(4, 3)

Me.lblInstalled .Name = "lblInstall ed"

Me.lblInstalled .Size = New System.Drawing. Size(79, 17)

Me.lblInstalled .TabIndex = 0

Me.lblInstalled .Text = "Not Installed"

'

'pnlStatus

'

Me.pnlStatus.Bl end = New
VbPowerPack.Ble ndFill(VbPowerP ack.BlendStyle. BackwardDiagona l,
System.Drawing. Color.Red, System.Drawing. Color.White)

Me.pnlStatus.Bo rderStyle = System.Windows. Forms.BorderSty le.Fixed3D

Me.pnlStatus.Co ntrols.Add(Me.l blStatus)

Me.pnlStatus.Lo cation = New System.Drawing. Point(155, 222)

Me.pnlStatus.Na me = "pnlStatus"

Me.pnlStatus.Si ze = New System.Drawing. Size(182, 27)

Me.pnlStatus.Ta bIndex = 7

Me.pnlStatus.Ta g = ""

'

'lblStatus

'

Me.lblStatus.Au toSize = True

Me.lblStatus.Ba ckColor = System.Drawing. Color.Transpare nt

Me.lblStatus.Fo nt = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.lblStatus.Lo cation = New System.Drawing. Point(4, 3)

Me.lblStatus.Na me = "lblStatus"

Me.lblStatus.Si ze = New System.Drawing. Size(55, 17)

Me.lblStatus.Ta bIndex = 0

Me.lblStatus.Te xt = "Stopped"

'

'lblStartupType

'

Me.lblStartupTy pe.AutoSize = True

Me.lblStartupTy pe.BackColor = System.Drawing. Color.Transpare nt

Me.lblStartupTy pe.Font = New System.Drawing. Font("Microsoft Sans Serif",
9.75!, System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.lblStartupTy pe.Location = New System.Drawing. Point(4, 3)

Me.lblStartupTy pe.Name = "lblStartupType "

Me.lblStartupTy pe.Size = New System.Drawing. Size(57, 17)

Me.lblStartupTy pe.TabIndex = 0

Me.lblStartupTy pe.Text = "Disabled"

'

'Label5

'

Me.Label5.AutoS ize = True

Me.Label5.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label5.Locat ion = New System.Drawing. Point(44, 27)

Me.Label5.Name = "Label5"

Me.Label5.Size = New System.Drawing. Size(57, 17)

Me.Label5.TabIn dex = 10

Me.Label5.Text = "Service :"

'

'lblService

'

Me.lblService.A utoSize = True

Me.lblService.B ackColor = System.Drawing. Color.Transpare nt

Me.lblService.F ont = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.lblService.L ocation = New System.Drawing. Point(161, 27)

Me.lblService.N ame = "lblService "

Me.lblService.S ize = New System.Drawing. Size(67, 17)

Me.lblService.T abIndex = 9

Me.lblService.T ext = "MyService"

'

'pnlStartupType

'

Me.pnlStartupTy pe.Blend = New
VbPowerPack.Ble ndFill(VbPowerP ack.BlendStyle. BackwardDiagona l,
System.Drawing. Color.Red, System.Drawing. Color.White)

Me.pnlStartupTy pe.BorderStyle = System.Windows. Forms.BorderSty le.Fixed3D

Me.pnlStartupTy pe.Controls.Add (Me.lblStartupT ype)

Me.pnlStartupTy pe.Location = New System.Drawing. Point(155, 172)

Me.pnlStartupTy pe.Name = "pnlStartupType "

Me.pnlStartupTy pe.Size = New System.Drawing. Size(182, 27)

Me.pnlStartupTy pe.TabIndex = 8

Me.pnlStartupTy pe.Tag = ""

'

'pnlInstalled

'

Me.pnlInstalled .Blend = New
VbPowerPack.Ble ndFill(VbPowerP ack.BlendStyle. BackwardDiagona l,
System.Drawing. Color.Red, System.Drawing. Color.White)

Me.pnlInstalled .BorderStyle = System.Windows. Forms.BorderSty le.Fixed3D

Me.pnlInstalled .Controls.Add(M e.lblInstalled)

Me.pnlInstalled .Location = New System.Drawing. Point(155, 122)

Me.pnlInstalled .Name = "pnlInstall ed"

Me.pnlInstalled .Size = New System.Drawing. Size(182, 27)

Me.pnlInstalled .TabIndex = 6

Me.pnlInstalled .Tag = ""

'

'pnlSoftware

'

Me.pnlSoftware. Blend = New
VbPowerPack.Ble ndFill(VbPowerP ack.BlendStyle. BackwardDiagona l,
System.Drawing. Color.Red, System.Drawing. Color.White)

Me.pnlSoftware. BorderStyle = System.Windows. Forms.BorderSty le.Fixed3D

Me.pnlSoftware. Controls.Add(Me .lblSoftware)

Me.pnlSoftware. Location = New System.Drawing. Point(155, 72)

Me.pnlSoftware. Name = "pnlSoftwar e"

Me.pnlSoftware. Size = New System.Drawing. Size(182, 27)

Me.pnlSoftware. TabIndex = 1

Me.pnlSoftware. Tag = ""

'

'btnStartupType

'

Me.btnStartupTy pe.Location = New System.Drawing. Point(353, 177)

Me.btnStartupTy pe.Name = "btnStartupType "

Me.btnStartupTy pe.Size = New System.Drawing. Size(52, 22)

Me.btnStartupTy pe.TabIndex = 12

Me.btnStartupTy pe.Text = "Change"

'

'btnStart

'

Me.btnStart.Loc ation = New System.Drawing. Point(353, 227)

Me.btnStart.Nam e = "btnStart"

Me.btnStart.Siz e = New System.Drawing. Size(52, 22)

Me.btnStart.Tab Index = 13

Me.btnStart.Tex t = "Start"

'

'btnStop

'

Me.btnStop.Loca tion = New System.Drawing. Point(412, 227)

Me.btnStop.Name = "btnStop"

Me.btnStop.Size = New System.Drawing. Size(52, 22)

Me.btnStop.TabI ndex = 14

Me.btnStop.Text = "Stop"

'

'btnPauze

'

Me.btnPauze.Loc ation = New System.Drawing. Point(471, 227)

Me.btnPauze.Nam e = "btnPauze"

Me.btnPauze.Siz e = New System.Drawing. Size(52, 22)

Me.btnPauze.Tab Index = 15

Me.btnPauze.Tex t = "Pauze"

'

'btnInstall

'

Me.btnInstall.L ocation = New System.Drawing. Point(353, 127)

Me.btnInstall.N ame = "btnInstall "

Me.btnInstall.S ize = New System.Drawing. Size(52, 22)

Me.btnInstall.T abIndex = 16

Me.btnInstall.T ext = "Install"

'

'frmController

'

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

Me.ClientSize = New System.Drawing. Size(540, 269)

Me.Controls.Add (Me.btnInstall)

Me.Controls.Add (Me.btnPauze)

Me.Controls.Add (Me.btnStop)

Me.Controls.Add (Me.btnStart)

Me.Controls.Add (Me.btnStartupT ype)

Me.Controls.Add (Me.Label5)

Me.Controls.Add (Me.lblService)

Me.Controls.Add (Me.pnlStartupT ype)

Me.Controls.Add (Me.pnlStatus)

Me.Controls.Add (Me.pnlInstalle d)

Me.Controls.Add (Me.Label4)

Me.Controls.Add (Me.Label3)

Me.Controls.Add (Me.Label2)

Me.Controls.Add (Me.Label1)

Me.Controls.Add (Me.pnlSoftware )

Me.Icon = CType(resources .GetObject("$th is.Icon"), System.Drawing. Icon)

Me.Name = "frmControl ler"

Me.Text = "SMS Server Service Controller"

Me.pnlStatus.Re sumeLayout(Fals e)

Me.pnlStatus.Pe rformLayout()

Me.pnlStartupTy pe.ResumeLayout (False)

Me.pnlStartupTy pe.PerformLayou t()

Me.pnlInstalled .ResumeLayout(F alse)

Me.pnlInstalled .PerformLayout( )

Me.pnlSoftware. ResumeLayout(Fa lse)

Me.pnlSoftware. PerformLayout()

Me.ResumeLayout (False)

Me.PerformLayou t()

End Sub

Friend WithEvents Label1 As System.Windows. Forms.Label

Friend WithEvents Label2 As System.Windows. Forms.Label

Friend WithEvents Label3 As System.Windows. Forms.Label

Friend WithEvents Label4 As System.Windows. Forms.Label

Friend WithEvents lblSoftware As System.Windows. Forms.Label

Friend WithEvents lblInstalled As System.Windows. Forms.Label

Friend WithEvents pnlStatus As VbPowerPack.Ble ndPanel

Friend WithEvents lblStatus As System.Windows. Forms.Label

Friend WithEvents lblStartupType As System.Windows. Forms.Label

Friend WithEvents Label5 As System.Windows. Forms.Label

Friend WithEvents lblService As System.Windows. Forms.Label

Friend WithEvents pnlStartupType As VbPowerPack.Ble ndPanel

Friend WithEvents pnlInstalled As VbPowerPack.Ble ndPanel

Friend WithEvents pnlSoftware As VbPowerPack.Ble ndPanel

Friend WithEvents btnStartupType As System.Windows. Forms.Button

Friend WithEvents btnStart As System.Windows. Forms.Button

Friend WithEvents btnStop As System.Windows. Forms.Button

Friend WithEvents btnPauze As System.Windows. Forms.Button

Friend WithEvents btnInstall As System.Windows. Forms.Button

End Class


'** THE app.config-file**

<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>

<system.diagnos tics>

<sources>

<!-- This section defines the logging configuration for My.Application. Log
in Windows Forms projects.-->

<source name="Microsoft .VisualBasic.My Services.Log.Wi ndowsFormsSourc e"
switchName="Def aultSwitch">

<listeners>

<add name="FileLog"/>

<!-- Uncomment the below section to write to the Application Event Log -->

<!--<add name="EventLog"/>-->

</listeners>

</source>

</sources>

<switches>

<add name="DefaultSw itch" value="Informat ion" />

</switches>

<sharedListener s>

<add name="FileLog"

type="System.Di agnostics.FileL ogTraceListener , Microsoft.Visua lBasic,
Version=8.0.120 0.0, Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a,
processorArchit ecture=MSIL"

initializeData= "FileLogWri ter"/>

<!-- Uncomment the below section and replace APPLICATION_NAM E with the name
of your application to write to the Application Event Log -->

<!--<add name="EventLog" type="System.Di agnostics.Event LogTraceListene r"
initializeData= "APPLICATION_NA ME"/-->

</sharedListeners >

</system.diagnost ics>

<appSettings>

<add key="MyService" value="SMS Service"></add>

<add key="MyServiceP ath" value="C:\Progr am Files\SMS Server\SMS
Service.exe"></add>

<add key="Applicatio n" value=""></add>

<add key="InstallUti l"
value="C:\WINNT \Microsoft.NET\ Framework\v2.0. 40607\InstallUt il.exe"></add>

</appSettings>

</configuration>
Aug 10 '06 #4
"Pieter" <pi**********@h otmail.comwrote in message
news:un******** ******@TK2MSFTN GP06.phx.gbl...
I've made once a small application (with Visual Studio 2005 Beta 1) that
controlled a service: It showed the status and allowed the user to change
the status etc.

I don't know if it's this what you are looking for:
This is great.

It shows me what I need.

Thanks,

Tom
>

'** THE frmController.v b-file
Option Explicit On

Imports System.ServiceP rocess

Imports System.Configur ation

Imports VbPowerPack

Imports Microsoft.Win32

Imports System.IO

Public Class frmController

Private m_svc As ServiceControll er

Private strMyService As String

Private WithEvents tmrRefresh As New Timers.Timer

Private Sub frmController_L oad(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

FillValues()

tmrRefresh.Inte rval = 5000

tmrRefresh.Star t()

End Sub

Private Sub FillValues()

'Service

strMyService = ConfigurationSe ttings.AppSetti ngs.Get("MyServ ice")

lblService.Text = strMyService

'Software

'ConfigurationS ettings.AppSett ings.Get("MySer vicePath")

If File.Exists(Con figurationSetti ngs.AppSettings .Get("MyService Path"))
Then

lblSoftware.Tex t = "Available"

pnlSoftware.Ble nd = New BlendFill(Blend Style.BackwardD iagonal,
Color.Green, Color.White)

Else

lblSoftware.Tex t = "Not Available"

pnlSoftware.Ble nd = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

End If

'Installed

EvaluateInstall ed()

End Sub

Private Sub EvaluateInstall ed()

If IsInstalled() Then

'installed

lblInstalled.Te xt = "Installed"

btnInstall.Text = "Uninstall"

pnlInstalled.Bl end = New BlendFill(Blend Style.BackwardD iagonal,
Color.Green, Color.White)

'StartupType

EvaluateStartup Type()

'Status

EvaluateStatus( )

Else

'installed

lblInstalled.Te xt = "Not Available"

btnInstall.Text = "Install"

pnlInstalled.Bl end = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

'startup type

lblStartupType. Text = "Disabled"

pnlStartupType. Blend = New BlendFill(Blend Style.BackwardD iagonal,
Color.Red, Color.White)

'status

lblStatus.Text = "Stopped"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

End If

End Sub

Private Function IsInstalled() As Boolean

'strMyService = ConfigurationSe ttings.AppSetti ngs.Get("MyServ ice")

IsInstalled = False

Dim installedServic es() As ServiceControll er

Dim tempService As ServiceControll er

installedServic es = ServiceControll er.GetServices

For Each tempService In installedServic es

If UCase(tempServi ce.ServiceName) = UCase(strMyServ ice) Then

'blnIsServiceIn stalled = true

m_svc = tempService

IsInstalled = True

End If

Next

End Function

Private Property ServiceStartupT ype() As ServiceStartMod e

Get

Dim RegValue As ServiceStartMod e

Dim RegKey As RegistryKey

RegKey =
Registry.LocalM achine.OpenSubK ey("SYSTEM\\Cur rentControlSet\ \Services\\" &
strMyService)

If Not (RegKey Is Nothing) Then

RegValue = CType(RegKey.Ge tValue("Start") , ServiceStartMod e)

RegKey.Close()

RegKey = Nothing

Return RegValue

Else

Return ServiceStartMod e.Disabled

End If

End Get

Set(ByVal value As ServiceStartMod e)

Dim RegKey As RegistryKey

RegKey =
Registry.LocalM achine.OpenSubK ey("SYSTEM\\Cur rentControlSet\ \Services\\" &
strMyService, True)

If Not (RegKey Is Nothing) Then

RegKey.SetValue ("Start", CType(value, Integer))

RegKey.Close()

RegKey = Nothing

Else

MessageBox.Show ("Cannot modify the Startup type.", "Startup Type",
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

End If

End Set

End Property

Private Sub EvaluateStartup Type()

'Startup Type

Select Case ServiceStartupT ype

Case ServiceStartMod e.Automatic

lblStartupType. Text = "Automatic"

pnlStartupType. Blend = New BlendFill(Blend Style.BackwardD iagonal,
Color.Green, Color.White)

Case ServiceStartMod e.Manual

lblStartupType. Text = "Manual"

pnlStartupType. Blend = New BlendFill(Blend Style.BackwardD iagonal,
Color.Orange, Color.White)

Case Else

lblStartupType. Text = "Disabled"

pnlStartupType. Blend = New BlendFill(Blend Style.BackwardD iagonal,
Color.Red, Color.White)

End Select

End Sub

Private Sub EvaluateStatus( )

'Status

Select Case m_svc.Status

Case ServiceControll erStatus.Contin uePending

lblStatus.Text = "Continue Pending"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Green,
Color.White)

Case ServiceControll erStatus.Paused

lblStatus.Text = "Paused"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Orange,
Color.White)

Case ServiceControll erStatus.PauseP ending

lblStatus.Text = "Pause Pending"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Orange,
Color.White)

Case ServiceControll erStatus.Runnin g

lblStatus.Text = "Started"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Green,
Color.White)

Case ServiceControll erStatus.StartP ending

lblStatus.Text = "Start Pending"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Green,
Color.White)

Case ServiceControll erStatus.StopPe nding

lblStatus.Text = "Stop Pending"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

Case Else

lblStatus.Text = "Stopped"

pnlStatus.Blend = New BlendFill(Blend Style.BackwardD iagonal, Color.Red,
Color.White)

End Select

End Sub

Private Sub btnStartupType_ Click(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnStartupType. Click

Select Case ServiceStartupT ype

Case ServiceStartMod e.Automatic

ServiceStartupT ype = ServiceStartMod e.Manual

Case ServiceStartMod e.Manual

ServiceStartupT ype = ServiceStartMod e.Disabled

Case Else

ServiceStartupT ype = ServiceStartMod e.Automatic

End Select

EvaluateStartup Type()

End Sub

Private Sub tmrRefresh_Elap sed(ByVal sender As Object, ByVal e As
System.Timers.E lapsedEventArgs ) Handles tmrRefresh.Elap sed

FillValues()

End Sub

Private Sub btnStart_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnStart.Click

Try

m_svc.Start()

EvaluateStatus( )

Catch ex As Exception

MessageBox.Show ("Excepction occured while Starting Service", "Service
Controller", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

End Try

End Sub

Private Sub btnStop_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnStop.Click

Try

m_svc.Stop()

EvaluateStatus( )

Catch ex As Exception

MessageBox.Show ("Excepction occured while Stopping Service", "Service
Controller", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

End Try

End Sub

Private Sub btnPauze_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnPauze.Click

Try

m_svc.Pause()

EvaluateStatus( )

Catch ex As Exception

MessageBox.Show ("Excepction occured while Pausing Service", "Service
Controller", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

End Try

End Sub

Public Overloads Sub RunExe(ByVal strName As String, ByVal strArg As
String)

Dim prcLogin As New Process

prcLogin.StartI nfo.UseShellExe cute = True

prcLogin.StartI nfo.RedirectSta ndardOutput = False

prcLogin.StartI nfo.FileName = strName

prcLogin.StartI nfo.Arguments = strArg

prcLogin.Start( )

prcLogin.Close( )

End Sub

Private Sub btnInstall_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnInstall.Clic k

Dim sArgs As String

If btnInstall.Text = "Install" Then

sArgs = " /name=""" & lblService.Text & """ """ &
ConfigurationSe ttings.AppSetti ngs.Get("MyServ icePath") & """"

RunExe(Configur ationSettings.A ppSettings.Get( "InstallUti l"), sArgs)

Else

sArgs = " /U /name=""" & lblService.Text & """ """ &
ConfigurationSe ttings.AppSetti ngs.Get("MyServ icePath") & """"

RunExe(Configur ationSettings.A ppSettings.Get( "InstallUti l"), sArgs)

End If

EvaluateInstall ed()

End Sub

End Class


'*** THE frmController.D esigner.vb-file**

Partial Public Class frmController

Inherits System.Windows. Forms.Form

<System.Diagnos tics.DebuggerNo nUserCode()_

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeCompo nent()

End Sub

'Form overrides dispose to clean up the component list.

<System.Diagnos tics.DebuggerNo nUserCode()_

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing AndAlso components IsNot Nothing Then

components.Disp ose()

End If

MyBase.Dispose( disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.Componen tModel.IContain er

'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.

<System.Diagnos tics.DebuggerSt epThrough()_

Private Sub InitializeCompo nent()

Dim resources As System.Componen tModel.Componen tResourceManage r = New
System.Componen tModel.Componen tResourceManage r(GetType(frmCo ntroller))

Me.Label1 = New System.Windows. Forms.Label

Me.Label2 = New System.Windows. Forms.Label

Me.Label3 = New System.Windows. Forms.Label

Me.Label4 = New System.Windows. Forms.Label

Me.lblSoftware = New System.Windows. Forms.Label

Me.lblInstalled = New System.Windows. Forms.Label

Me.pnlStatus = New VbPowerPack.Ble ndPanel

Me.lblStatus = New System.Windows. Forms.Label

Me.lblStartupTy pe = New System.Windows. Forms.Label

Me.Label5 = New System.Windows. Forms.Label

Me.lblService = New System.Windows. Forms.Label

Me.pnlStartupTy pe = New VbPowerPack.Ble ndPanel

Me.pnlInstalled = New VbPowerPack.Ble ndPanel

Me.pnlSoftware = New VbPowerPack.Ble ndPanel

Me.btnStartupTy pe = New System.Windows. Forms.Button

Me.btnStart = New System.Windows. Forms.Button

Me.btnStop = New System.Windows. Forms.Button

Me.btnPauze = New System.Windows. Forms.Button

Me.btnInstall = New System.Windows. Forms.Button

Me.pnlStatus.Su spendLayout()

Me.pnlStartupTy pe.SuspendLayou t()

Me.pnlInstalled .SuspendLayout( )

Me.pnlSoftware. SuspendLayout()

Me.SuspendLayou t()

'

'Label1

'

Me.Label1.AutoS ize = True

Me.Label1.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label1.Locat ion = New System.Drawing. Point(44, 77)

Me.Label1.Name = "Label1"

Me.Label1.Size = New System.Drawing. Size(78, 17)

Me.Label1.TabIn dex = 2

Me.Label1.Text = "Applicatio n :"

'

'Label2

'

Me.Label2.AutoS ize = True

Me.Label2.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label2.Locat ion = New System.Drawing. Point(44, 127)

Me.Label2.Margi n = New System.Windows. Forms.Padding(3 , 3, 3, 1)

Me.Label2.Name = "Label2"

Me.Label2.Size = New System.Drawing. Size(62, 17)

Me.Label2.TabIn dex = 3

Me.Label2.Text = "Installed :"

'

'Label3

'

Me.Label3.AutoS ize = True

Me.Label3.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label3.Locat ion = New System.Drawing. Point(44, 177)

Me.Label3.Margi n = New System.Windows. Forms.Padding(3 , 1, 3, 3)

Me.Label3.Name = "Label3"

Me.Label3.Size = New System.Drawing. Size(89, 17)

Me.Label3.TabIn dex = 4

Me.Label3.Text = "Startup Type :"

'

'Label4

'

Me.Label4.AutoS ize = True

Me.Label4.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label4.Locat ion = New System.Drawing. Point(44, 227)

Me.Label4.Name = "Label4"

Me.Label4.Size = New System.Drawing. Size(50, 17)

Me.Label4.TabIn dex = 5

Me.Label4.Text = "Status :"

'

'lblSoftware

'

Me.lblSoftware. AutoSize = True

Me.lblSoftware. BackColor = System.Drawing. Color.Transpare nt

Me.lblSoftware. Font = New System.Drawing. Font("Microsoft Sans Serif",
9.75!, System.Drawing. FontStyle.Regul ar,
System.Drawing. GraphicsUnit.Po int, CType(0, Byte))

Me.lblSoftware. Location = New System.Drawing. Point(4, 3)

Me.lblSoftware. Name = "lblSoftwar e"

Me.lblSoftware. Size = New System.Drawing. Size(84, 17)

Me.lblSoftware. TabIndex = 0

Me.lblSoftware. Text = "Not Available"

'

'lblInstalled

'

Me.lblInstalled .AutoSize = True

Me.lblInstalled .BackColor = System.Drawing. Color.Transpare nt

Me.lblInstalled .Font = New System.Drawing. Font("Microsoft Sans Serif",
9.75!, System.Drawing. FontStyle.Regul ar,
System.Drawing. GraphicsUnit.Po int, CType(0, Byte))

Me.lblInstalled .Location = New System.Drawing. Point(4, 3)

Me.lblInstalled .Name = "lblInstall ed"

Me.lblInstalled .Size = New System.Drawing. Size(79, 17)

Me.lblInstalled .TabIndex = 0

Me.lblInstalled .Text = "Not Installed"

'

'pnlStatus

'

Me.pnlStatus.Bl end = New
VbPowerPack.Ble ndFill(VbPowerP ack.BlendStyle. BackwardDiagona l,
System.Drawing. Color.Red, System.Drawing. Color.White)

Me.pnlStatus.Bo rderStyle = System.Windows. Forms.BorderSty le.Fixed3D

Me.pnlStatus.Co ntrols.Add(Me.l blStatus)

Me.pnlStatus.Lo cation = New System.Drawing. Point(155, 222)

Me.pnlStatus.Na me = "pnlStatus"

Me.pnlStatus.Si ze = New System.Drawing. Size(182, 27)

Me.pnlStatus.Ta bIndex = 7

Me.pnlStatus.Ta g = ""

'

'lblStatus

'

Me.lblStatus.Au toSize = True

Me.lblStatus.Ba ckColor = System.Drawing. Color.Transpare nt

Me.lblStatus.Fo nt = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.lblStatus.Lo cation = New System.Drawing. Point(4, 3)

Me.lblStatus.Na me = "lblStatus"

Me.lblStatus.Si ze = New System.Drawing. Size(55, 17)

Me.lblStatus.Ta bIndex = 0

Me.lblStatus.Te xt = "Stopped"

'

'lblStartupType

'

Me.lblStartupTy pe.AutoSize = True

Me.lblStartupTy pe.BackColor = System.Drawing. Color.Transpare nt

Me.lblStartupTy pe.Font = New System.Drawing. Font("Microsoft Sans Serif",
9.75!, System.Drawing. FontStyle.Regul ar,
System.Drawing. GraphicsUnit.Po int, CType(0, Byte))

Me.lblStartupTy pe.Location = New System.Drawing. Point(4, 3)

Me.lblStartupTy pe.Name = "lblStartupType "

Me.lblStartupTy pe.Size = New System.Drawing. Size(57, 17)

Me.lblStartupTy pe.TabIndex = 0

Me.lblStartupTy pe.Text = "Disabled"

'

'Label5

'

Me.Label5.AutoS ize = True

Me.Label5.Font = New System.Drawing. Font("Microsoft Sans Serif", 9.75!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Me.Label5.Locat ion = New System.Drawing. Point(44, 27)

Me.Label5.Name = "Label5"

Me.Label5.Size = New System.Drawing. Size(57, 17)

Me.Label5.TabIn dex = 10

Me.Label5.Text = "Service :"

'

'lblService

'

Me.lblService.A utoSize = True

Me.lblService.B ackColor = System.Drawing. Color.Transpare nt

Me.lblService.F ont = New System.Drawing. Font("Microsoft Sans Serif",
9.75!, System.Drawing. FontStyle.Regul ar,
System.Drawing. GraphicsUnit.Po int, CType(0, Byte))

Me.lblService.L ocation = New System.Drawing. Point(161, 27)

Me.lblService.N ame = "lblService "

Me.lblService.S ize = New System.Drawing. Size(67, 17)

Me.lblService.T abIndex = 9

Me.lblService.T ext = "MyService"

'

'pnlStartupType

'

Me.pnlStartupTy pe.Blend = New
VbPowerPack.Ble ndFill(VbPowerP ack.BlendStyle. BackwardDiagona l,
System.Drawing. Color.Red, System.Drawing. Color.White)

Me.pnlStartupTy pe.BorderStyle = System.Windows. Forms.BorderSty le.Fixed3D

Me.pnlStartupTy pe.Controls.Add (Me.lblStartupT ype)

Me.pnlStartupTy pe.Location = New System.Drawing. Point(155, 172)

Me.pnlStartupTy pe.Name = "pnlStartupType "

Me.pnlStartupTy pe.Size = New System.Drawing. Size(182, 27)

Me.pnlStartupTy pe.TabIndex = 8

Me.pnlStartupTy pe.Tag = ""

'

'pnlInstalled

'

Me.pnlInstalled .Blend = New
VbPowerPack.Ble ndFill(VbPowerP ack.BlendStyle. BackwardDiagona l,
System.Drawing. Color.Red, System.Drawing. Color.White)

Me.pnlInstalled .BorderStyle = System.Windows. Forms.BorderSty le.Fixed3D

Me.pnlInstalled .Controls.Add(M e.lblInstalled)

Me.pnlInstalled .Location = New System.Drawing. Point(155, 122)

Me.pnlInstalled .Name = "pnlInstall ed"

Me.pnlInstalled .Size = New System.Drawing. Size(182, 27)

Me.pnlInstalled .TabIndex = 6

Me.pnlInstalled .Tag = ""

'

'pnlSoftware

'

Me.pnlSoftware. Blend = New
VbPowerPack.Ble ndFill(VbPowerP ack.BlendStyle. BackwardDiagona l,
System.Drawing. Color.Red, System.Drawing. Color.White)

Me.pnlSoftware. BorderStyle = System.Windows. Forms.BorderSty le.Fixed3D

Me.pnlSoftware. Controls.Add(Me .lblSoftware)

Me.pnlSoftware. Location = New System.Drawing. Point(155, 72)

Me.pnlSoftware. Name = "pnlSoftwar e"

Me.pnlSoftware. Size = New System.Drawing. Size(182, 27)

Me.pnlSoftware. TabIndex = 1

Me.pnlSoftware. Tag = ""

'

'btnStartupType

'

Me.btnStartupTy pe.Location = New System.Drawing. Point(353, 177)

Me.btnStartupTy pe.Name = "btnStartupType "

Me.btnStartupTy pe.Size = New System.Drawing. Size(52, 22)

Me.btnStartupTy pe.TabIndex = 12

Me.btnStartupTy pe.Text = "Change"

'

'btnStart

'

Me.btnStart.Loc ation = New System.Drawing. Point(353, 227)

Me.btnStart.Nam e = "btnStart"

Me.btnStart.Siz e = New System.Drawing. Size(52, 22)

Me.btnStart.Tab Index = 13

Me.btnStart.Tex t = "Start"

'

'btnStop

'

Me.btnStop.Loca tion = New System.Drawing. Point(412, 227)

Me.btnStop.Name = "btnStop"

Me.btnStop.Size = New System.Drawing. Size(52, 22)

Me.btnStop.TabI ndex = 14

Me.btnStop.Text = "Stop"

'

'btnPauze

'

Me.btnPauze.Loc ation = New System.Drawing. Point(471, 227)

Me.btnPauze.Nam e = "btnPauze"

Me.btnPauze.Siz e = New System.Drawing. Size(52, 22)

Me.btnPauze.Tab Index = 15

Me.btnPauze.Tex t = "Pauze"

'

'btnInstall

'

Me.btnInstall.L ocation = New System.Drawing. Point(353, 127)

Me.btnInstall.N ame = "btnInstall "

Me.btnInstall.S ize = New System.Drawing. Size(52, 22)

Me.btnInstall.T abIndex = 16

Me.btnInstall.T ext = "Install"

'

'frmController

'

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

Me.ClientSize = New System.Drawing. Size(540, 269)

Me.Controls.Add (Me.btnInstall)

Me.Controls.Add (Me.btnPauze)

Me.Controls.Add (Me.btnStop)

Me.Controls.Add (Me.btnStart)

Me.Controls.Add (Me.btnStartupT ype)

Me.Controls.Add (Me.Label5)

Me.Controls.Add (Me.lblService)

Me.Controls.Add (Me.pnlStartupT ype)

Me.Controls.Add (Me.pnlStatus)

Me.Controls.Add (Me.pnlInstalle d)

Me.Controls.Add (Me.Label4)

Me.Controls.Add (Me.Label3)

Me.Controls.Add (Me.Label2)

Me.Controls.Add (Me.Label1)

Me.Controls.Add (Me.pnlSoftware )

Me.Icon = CType(resources .GetObject("$th is.Icon"), System.Drawing. Icon)

Me.Name = "frmControl ler"

Me.Text = "SMS Server Service Controller"

Me.pnlStatus.Re sumeLayout(Fals e)

Me.pnlStatus.Pe rformLayout()

Me.pnlStartupTy pe.ResumeLayout (False)

Me.pnlStartupTy pe.PerformLayou t()

Me.pnlInstalled .ResumeLayout(F alse)

Me.pnlInstalled .PerformLayout( )

Me.pnlSoftware. ResumeLayout(Fa lse)

Me.pnlSoftware. PerformLayout()

Me.ResumeLayout (False)

Me.PerformLayou t()

End Sub

Friend WithEvents Label1 As System.Windows. Forms.Label

Friend WithEvents Label2 As System.Windows. Forms.Label

Friend WithEvents Label3 As System.Windows. Forms.Label

Friend WithEvents Label4 As System.Windows. Forms.Label

Friend WithEvents lblSoftware As System.Windows. Forms.Label

Friend WithEvents lblInstalled As System.Windows. Forms.Label

Friend WithEvents pnlStatus As VbPowerPack.Ble ndPanel

Friend WithEvents lblStatus As System.Windows. Forms.Label

Friend WithEvents lblStartupType As System.Windows. Forms.Label

Friend WithEvents Label5 As System.Windows. Forms.Label

Friend WithEvents lblService As System.Windows. Forms.Label

Friend WithEvents pnlStartupType As VbPowerPack.Ble ndPanel

Friend WithEvents pnlInstalled As VbPowerPack.Ble ndPanel

Friend WithEvents pnlSoftware As VbPowerPack.Ble ndPanel

Friend WithEvents btnStartupType As System.Windows. Forms.Button

Friend WithEvents btnStart As System.Windows. Forms.Button

Friend WithEvents btnStop As System.Windows. Forms.Button

Friend WithEvents btnPauze As System.Windows. Forms.Button

Friend WithEvents btnInstall As System.Windows. Forms.Button

End Class


'** THE app.config-file**

<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>

<system.diagnos tics>

<sources>

<!-- This section defines the logging configuration for My.Application. Log
in Windows Forms projects.-->

<source name="Microsoft .VisualBasic.My Services.Log.Wi ndowsFormsSourc e"
switchName="Def aultSwitch">

<listeners>

<add name="FileLog"/>

<!-- Uncomment the below section to write to the Application Event Log -->

<!--<add name="EventLog"/>-->

</listeners>

</source>

</sources>

<switches>

<add name="DefaultSw itch" value="Informat ion" />

</switches>

<sharedListener s>

<add name="FileLog"

type="System.Di agnostics.FileL ogTraceListener , Microsoft.Visua lBasic,
Version=8.0.120 0.0, Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a,
processorArchit ecture=MSIL"

initializeData= "FileLogWri ter"/>

<!-- Uncomment the below section and replace APPLICATION_NAM E with the
name of your application to write to the Application Event Log -->

<!--<add name="EventLog" type="System.Di agnostics.Event LogTraceListene r"
initializeData= "APPLICATION_NA ME"/-->

</sharedListeners >

</system.diagnost ics>

<appSettings>

<add key="MyService" value="SMS Service"></add>

<add key="MyServiceP ath" value="C:\Progr am Files\SMS Server\SMS
Service.exe"></add>

<add key="Applicatio n" value=""></add>

<add key="InstallUti l"
value="C:\WINNT \Microsoft.NET\ Framework\v2.0. 40607\InstallUt il.exe"></add>

</appSettings>

</configuration>


Aug 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2212
by: Brad Jones | last post by:
Hello, I'm hoping someone can give me some help or guidance here. I'm not sure if this is even the best group to post to for this. Our OEM equipment's software architecture relies heavily on a "master" windows service. This responsibility of this service is to launch 10 or so other applications, some of which have GUI's. These applications need to be running whether somebody is logged in or not. There is no communication required between...
2
2578
by: epaetz | last post by:
I'm getting Not associated with a trusted SQL Server connection errors on a .Net windows service I wrote, when it's running on my application server. It's not a problem with mixed mode security. I'm set for mixed mode and I've been running the service on the app server for over a month with no problem. My database is running on a second server and both are under the same domain. The problem has occurred twice over the last two months.
7
712
by: Mike | last post by:
I want to create a windows service that will monitor another window service. what i need for the service to do is, if a service is stopped I need it to start the service back up example: service 1 - my service watches service 2 - windows service service 2 is stopped - service 1 starts service 2
2
5926
by: Chris Podmore | last post by:
I don't know if this is the correct newsgroup but I couldn't find one for Windows Services Is it possible to check that a Windows Service is still running from another machine The idea being a couple of machines will be running my Windows Services to handle certain parts of our application, these machines will be located in the server room. I would like to create an application that runs on one of the users PC's that checks that these...
3
3689
by: Doug Bailey | last post by:
I am trying to control a Windows Service via a Web Service interface. (I am developing in .NET2003) I am using the ServiceController object which allows me to read the state of the services with no problems. However, I am not able to start or stop the service unless I go through the process of impersonating an administrative user. (See MSDN KB 306158) Since it appears to be a privilege issue, I set the folders in IIS holding the Web...
5
1909
by: Tony | last post by:
Every 10 seconds I need to search a SQL table for orders to print. The orders are created through WebForms on ASP.NET clients. The orders should not print until 10 minutes before they are due. The network printer will be available from the server running IIS and SQL Server 2000. If this were a Windows Forms application, then I would create a system timer in Form1.Load(). How is this done in an ASP.NET application?
2
6893
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app (which is the UI used to adjust the actions taken by, and the schedule of the service), then a privileged user thread should be used in the UI - no service required. But... "A windows service enables the creation of long-running executable
7
25652
by: Joris De Groote | last post by:
Hi, can vb check if a windows service is running or not? ( Webclient ) Thanks Joris
12
14529
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
12
12826
by: Shadlan | last post by:
Hi. I need to know if a service is running on my server. Is there any PHP instruction that I can use to do this?
0
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9055
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8947
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5891
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4392
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3076
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.