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.
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 4 4140
Hi,
I think u may take help of System.Diagnostics.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 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.
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
"Bharathi kumar" <bh************@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Hi,
I think u may take help of System.Diagnostics.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 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.
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
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.vb-file
Option Explicit On
Imports System.ServiceProcess
Imports System.Configuration
Imports VbPowerPack
Imports Microsoft.Win32
Imports System.IO
Public Class frmController
Private m_svc As ServiceController
Private strMyService As String
Private WithEvents tmrRefresh As New Timers.Timer
Private Sub frmController_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
FillValues()
tmrRefresh.Interval = 5000
tmrRefresh.Start()
End Sub
Private Sub FillValues()
'Service
strMyService = ConfigurationSettings.AppSettings.Get("MyService")
lblService.Text = strMyService
'Software
'ConfigurationSettings.AppSettings.Get("MyServiceP ath")
If File.Exists(ConfigurationSettings.AppSettings.Get( "MyServicePath")) Then
lblSoftware.Text = "Available"
pnlSoftware.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Green,
Color.White)
Else
lblSoftware.Text = "Not Available"
pnlSoftware.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
End If
'Installed
EvaluateInstalled()
End Sub
Private Sub EvaluateInstalled()
If IsInstalled() Then
'installed
lblInstalled.Text = "Installed"
btnInstall.Text = "Uninstall"
pnlInstalled.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Green,
Color.White)
'StartupType
EvaluateStartupType()
'Status
EvaluateStatus()
Else
'installed
lblInstalled.Text = "Not Available"
btnInstall.Text = "Install"
pnlInstalled.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
'startup type
lblStartupType.Text = "Disabled"
pnlStartupType.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
'status
lblStatus.Text = "Stopped"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
End If
End Sub
Private Function IsInstalled() As Boolean
'strMyService = ConfigurationSettings.AppSettings.Get("MyService")
IsInstalled = False
Dim installedServices() As ServiceController
Dim tempService As ServiceController
installedServices = ServiceController.GetServices
For Each tempService In installedServices
If UCase(tempService.ServiceName) = UCase(strMyService) Then
'blnIsServiceInstalled = true
m_svc = tempService
IsInstalled = True
End If
Next
End Function
Private Property ServiceStartupType() As ServiceStartMode
Get
Dim RegValue As ServiceStartMode
Dim RegKey As RegistryKey
RegKey =
Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentC ontrolSet\\Services\\" &
strMyService)
If Not (RegKey Is Nothing) Then
RegValue = CType(RegKey.GetValue("Start"), ServiceStartMode)
RegKey.Close()
RegKey = Nothing
Return RegValue
Else
Return ServiceStartMode.Disabled
End If
End Get
Set(ByVal value As ServiceStartMode)
Dim RegKey As RegistryKey
RegKey =
Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentC ontrolSet\\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",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Set
End Property
Private Sub EvaluateStartupType()
'Startup Type
Select Case ServiceStartupType
Case ServiceStartMode.Automatic
lblStartupType.Text = "Automatic"
pnlStartupType.Blend = New BlendFill(BlendStyle.BackwardDiagonal,
Color.Green, Color.White)
Case ServiceStartMode.Manual
lblStartupType.Text = "Manual"
pnlStartupType.Blend = New BlendFill(BlendStyle.BackwardDiagonal,
Color.Orange, Color.White)
Case Else
lblStartupType.Text = "Disabled"
pnlStartupType.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
End Select
End Sub
Private Sub EvaluateStatus()
'Status
Select Case m_svc.Status
Case ServiceControllerStatus.ContinuePending
lblStatus.Text = "Continue Pending"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Green,
Color.White)
Case ServiceControllerStatus.Paused
lblStatus.Text = "Paused"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Orange,
Color.White)
Case ServiceControllerStatus.PausePending
lblStatus.Text = "Pause Pending"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Orange,
Color.White)
Case ServiceControllerStatus.Running
lblStatus.Text = "Started"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Green,
Color.White)
Case ServiceControllerStatus.StartPending
lblStatus.Text = "Start Pending"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Green,
Color.White)
Case ServiceControllerStatus.StopPending
lblStatus.Text = "Stop Pending"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
Case Else
lblStatus.Text = "Stopped"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
End Select
End Sub
Private Sub btnStartupType_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStartupType.Click
Select Case ServiceStartupType
Case ServiceStartMode.Automatic
ServiceStartupType = ServiceStartMode.Manual
Case ServiceStartMode.Manual
ServiceStartupType = ServiceStartMode.Disabled
Case Else
ServiceStartupType = ServiceStartMode.Automatic
End Select
EvaluateStartupType()
End Sub
Private Sub tmrRefresh_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles tmrRefresh.Elapsed
FillValues()
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStart.Click
Try
m_svc.Start()
EvaluateStatus()
Catch ex As Exception
MessageBox.Show("Excepction occured while Starting Service", "Service
Controller", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStop.Click
Try
m_svc.Stop()
EvaluateStatus()
Catch ex As Exception
MessageBox.Show("Excepction occured while Stopping Service", "Service
Controller", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Sub
Private Sub btnPauze_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPauze.Click
Try
m_svc.Pause()
EvaluateStatus()
Catch ex As Exception
MessageBox.Show("Excepction occured while Pausing Service", "Service
Controller", MessageBoxButtons.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.StartInfo.UseShellExecute = True
prcLogin.StartInfo.RedirectStandardOutput = False
prcLogin.StartInfo.FileName = strName
prcLogin.StartInfo.Arguments = strArg
prcLogin.Start()
prcLogin.Close()
End Sub
Private Sub btnInstall_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnInstall.Click
Dim sArgs As String
If btnInstall.Text = "Install" Then
sArgs = " /name=""" & lblService.Text & """ """ &
ConfigurationSettings.AppSettings.Get("MyServicePa th") & """"
RunExe(ConfigurationSettings.AppSettings.Get("Inst allUtil"), sArgs)
Else
sArgs = " /U /name=""" & lblService.Text & """ """ &
ConfigurationSettings.AppSettings.Get("MyServicePa th") & """"
RunExe(ConfigurationSettings.AppSettings.Get("Inst allUtil"), sArgs)
End If
EvaluateInstalled()
End Sub
End Class
'*** THE frmController.Designer.vb-file**
Partial Public Class frmController
Inherits System.Windows.Forms.Form
<System.Diagnostics.DebuggerNonUserCode()_
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
End Sub
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()_
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
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.
<System.Diagnostics.DebuggerStepThrough()_
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New
System.ComponentModel.ComponentResourceManager(Get Type(frmController))
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.BlendPanel
Me.lblStatus = New System.Windows.Forms.Label
Me.lblStartupType = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.lblService = New System.Windows.Forms.Label
Me.pnlStartupType = New VbPowerPack.BlendPanel
Me.pnlInstalled = New VbPowerPack.BlendPanel
Me.pnlSoftware = New VbPowerPack.BlendPanel
Me.btnStartupType = 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.SuspendLayout()
Me.pnlStartupType.SuspendLayout()
Me.pnlInstalled.SuspendLayout()
Me.pnlSoftware.SuspendLayout()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(44, 77)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(78, 17)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Application :"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(44, 127)
Me.Label2.Margin = New System.Windows.Forms.Padding(3, 3, 3, 1)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(62, 17)
Me.Label2.TabIndex = 3
Me.Label2.Text = "Installed :"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(44, 177)
Me.Label3.Margin = New System.Windows.Forms.Padding(3, 1, 3, 3)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(89, 17)
Me.Label3.TabIndex = 4
Me.Label3.Text = "Startup Type :"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(44, 227)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(50, 17)
Me.Label4.TabIndex = 5
Me.Label4.Text = "Status :"
'
'lblSoftware
'
Me.lblSoftware.AutoSize = True
Me.lblSoftware.BackColor = System.Drawing.Color.Transparent
Me.lblSoftware.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.lblSoftware.Location = New System.Drawing.Point(4, 3)
Me.lblSoftware.Name = "lblSoftware"
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.Transparent
Me.lblInstalled.Font = New System.Drawing.Font("Microsoft Sans Serif",
9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.lblInstalled.Location = New System.Drawing.Point(4, 3)
Me.lblInstalled.Name = "lblInstalled"
Me.lblInstalled.Size = New System.Drawing.Size(79, 17)
Me.lblInstalled.TabIndex = 0
Me.lblInstalled.Text = "Not Installed"
'
'pnlStatus
'
Me.pnlStatus.Blend = New
VbPowerPack.BlendFill(VbPowerPack.BlendStyle.Backw ardDiagonal,
System.Drawing.Color.Red, System.Drawing.Color.White)
Me.pnlStatus.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pnlStatus.Controls.Add(Me.lblStatus)
Me.pnlStatus.Location = New System.Drawing.Point(155, 222)
Me.pnlStatus.Name = "pnlStatus"
Me.pnlStatus.Size = New System.Drawing.Size(182, 27)
Me.pnlStatus.TabIndex = 7
Me.pnlStatus.Tag = ""
'
'lblStatus
'
Me.lblStatus.AutoSize = True
Me.lblStatus.BackColor = System.Drawing.Color.Transparent
Me.lblStatus.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.lblStatus.Location = New System.Drawing.Point(4, 3)
Me.lblStatus.Name = "lblStatus"
Me.lblStatus.Size = New System.Drawing.Size(55, 17)
Me.lblStatus.TabIndex = 0
Me.lblStatus.Text = "Stopped"
'
'lblStartupType
'
Me.lblStartupType.AutoSize = True
Me.lblStartupType.BackColor = System.Drawing.Color.Transparent
Me.lblStartupType.Font = New System.Drawing.Font("Microsoft Sans Serif",
9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.lblStartupType.Location = New System.Drawing.Point(4, 3)
Me.lblStartupType.Name = "lblStartupType"
Me.lblStartupType.Size = New System.Drawing.Size(57, 17)
Me.lblStartupType.TabIndex = 0
Me.lblStartupType.Text = "Disabled"
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label5.Location = New System.Drawing.Point(44, 27)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(57, 17)
Me.Label5.TabIndex = 10
Me.Label5.Text = "Service :"
'
'lblService
'
Me.lblService.AutoSize = True
Me.lblService.BackColor = System.Drawing.Color.Transparent
Me.lblService.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.lblService.Location = New System.Drawing.Point(161, 27)
Me.lblService.Name = "lblService"
Me.lblService.Size = New System.Drawing.Size(67, 17)
Me.lblService.TabIndex = 9
Me.lblService.Text = "MyService"
'
'pnlStartupType
'
Me.pnlStartupType.Blend = New
VbPowerPack.BlendFill(VbPowerPack.BlendStyle.Backw ardDiagonal,
System.Drawing.Color.Red, System.Drawing.Color.White)
Me.pnlStartupType.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pnlStartupType.Controls.Add(Me.lblStartupType)
Me.pnlStartupType.Location = New System.Drawing.Point(155, 172)
Me.pnlStartupType.Name = "pnlStartupType"
Me.pnlStartupType.Size = New System.Drawing.Size(182, 27)
Me.pnlStartupType.TabIndex = 8
Me.pnlStartupType.Tag = ""
'
'pnlInstalled
'
Me.pnlInstalled.Blend = New
VbPowerPack.BlendFill(VbPowerPack.BlendStyle.Backw ardDiagonal,
System.Drawing.Color.Red, System.Drawing.Color.White)
Me.pnlInstalled.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pnlInstalled.Controls.Add(Me.lblInstalled)
Me.pnlInstalled.Location = New System.Drawing.Point(155, 122)
Me.pnlInstalled.Name = "pnlInstalled"
Me.pnlInstalled.Size = New System.Drawing.Size(182, 27)
Me.pnlInstalled.TabIndex = 6
Me.pnlInstalled.Tag = ""
'
'pnlSoftware
'
Me.pnlSoftware.Blend = New
VbPowerPack.BlendFill(VbPowerPack.BlendStyle.Backw ardDiagonal,
System.Drawing.Color.Red, System.Drawing.Color.White)
Me.pnlSoftware.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pnlSoftware.Controls.Add(Me.lblSoftware)
Me.pnlSoftware.Location = New System.Drawing.Point(155, 72)
Me.pnlSoftware.Name = "pnlSoftware"
Me.pnlSoftware.Size = New System.Drawing.Size(182, 27)
Me.pnlSoftware.TabIndex = 1
Me.pnlSoftware.Tag = ""
'
'btnStartupType
'
Me.btnStartupType.Location = New System.Drawing.Point(353, 177)
Me.btnStartupType.Name = "btnStartupType"
Me.btnStartupType.Size = New System.Drawing.Size(52, 22)
Me.btnStartupType.TabIndex = 12
Me.btnStartupType.Text = "Change"
'
'btnStart
'
Me.btnStart.Location = New System.Drawing.Point(353, 227)
Me.btnStart.Name = "btnStart"
Me.btnStart.Size = New System.Drawing.Size(52, 22)
Me.btnStart.TabIndex = 13
Me.btnStart.Text = "Start"
'
'btnStop
'
Me.btnStop.Location = New System.Drawing.Point(412, 227)
Me.btnStop.Name = "btnStop"
Me.btnStop.Size = New System.Drawing.Size(52, 22)
Me.btnStop.TabIndex = 14
Me.btnStop.Text = "Stop"
'
'btnPauze
'
Me.btnPauze.Location = New System.Drawing.Point(471, 227)
Me.btnPauze.Name = "btnPauze"
Me.btnPauze.Size = New System.Drawing.Size(52, 22)
Me.btnPauze.TabIndex = 15
Me.btnPauze.Text = "Pauze"
'
'btnInstall
'
Me.btnInstall.Location = New System.Drawing.Point(353, 127)
Me.btnInstall.Name = "btnInstall"
Me.btnInstall.Size = New System.Drawing.Size(52, 22)
Me.btnInstall.TabIndex = 16
Me.btnInstall.Text = "Install"
'
'frmController
'
Me.AutoScaleBaseSize = 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.btnStartupType)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.lblService)
Me.Controls.Add(Me.pnlStartupType)
Me.Controls.Add(Me.pnlStatus)
Me.Controls.Add(Me.pnlInstalled)
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("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmController"
Me.Text = "SMS Server Service Controller"
Me.pnlStatus.ResumeLayout(False)
Me.pnlStatus.PerformLayout()
Me.pnlStartupType.ResumeLayout(False)
Me.pnlStartupType.PerformLayout()
Me.pnlInstalled.ResumeLayout(False)
Me.pnlInstalled.PerformLayout()
Me.pnlSoftware.ResumeLayout(False)
Me.pnlSoftware.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
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.BlendPanel
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.BlendPanel
Friend WithEvents pnlInstalled As VbPowerPack.BlendPanel
Friend WithEvents pnlSoftware As VbPowerPack.BlendPanel
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" ?>
<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log
in Windows Forms projects.-->
<source name="Microsoft.VisualBasic.MyServices.Log.Windows FormsSource"
switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="System.Diagnostics.FileLogTraceListener, Microsoft.VisualBasic,
Version=8.0.1200.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name
of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener"
initializeData="APPLICATION_NAME"/-->
</sharedListeners>
</system.diagnostics>
<appSettings>
<add key="MyService" value="SMS Service"></add>
<add key="MyServicePath" value="C:\Program Files\SMS Server\SMS
Service.exe"></add>
<add key="Application" value=""></add>
<add key="InstallUtil"
value="C:\WINNT\Microsoft.NET\Framework\v2.0.40607 \InstallUtil.exe"></add>
</appSettings>
</configuration>
"Pieter" <pi**********@hotmail.comwrote in message
news:un**************@TK2MSFTNGP06.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.vb-file
Option Explicit On
Imports System.ServiceProcess
Imports System.Configuration
Imports VbPowerPack
Imports Microsoft.Win32
Imports System.IO
Public Class frmController
Private m_svc As ServiceController
Private strMyService As String
Private WithEvents tmrRefresh As New Timers.Timer
Private Sub frmController_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
FillValues()
tmrRefresh.Interval = 5000
tmrRefresh.Start()
End Sub
Private Sub FillValues()
'Service
strMyService = ConfigurationSettings.AppSettings.Get("MyService")
lblService.Text = strMyService
'Software
'ConfigurationSettings.AppSettings.Get("MyServiceP ath")
If File.Exists(ConfigurationSettings.AppSettings.Get( "MyServicePath"))
Then
lblSoftware.Text = "Available"
pnlSoftware.Blend = New BlendFill(BlendStyle.BackwardDiagonal,
Color.Green, Color.White)
Else
lblSoftware.Text = "Not Available"
pnlSoftware.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
End If
'Installed
EvaluateInstalled()
End Sub
Private Sub EvaluateInstalled()
If IsInstalled() Then
'installed
lblInstalled.Text = "Installed"
btnInstall.Text = "Uninstall"
pnlInstalled.Blend = New BlendFill(BlendStyle.BackwardDiagonal,
Color.Green, Color.White)
'StartupType
EvaluateStartupType()
'Status
EvaluateStatus()
Else
'installed
lblInstalled.Text = "Not Available"
btnInstall.Text = "Install"
pnlInstalled.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
'startup type
lblStartupType.Text = "Disabled"
pnlStartupType.Blend = New BlendFill(BlendStyle.BackwardDiagonal,
Color.Red, Color.White)
'status
lblStatus.Text = "Stopped"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
End If
End Sub
Private Function IsInstalled() As Boolean
'strMyService = ConfigurationSettings.AppSettings.Get("MyService")
IsInstalled = False
Dim installedServices() As ServiceController
Dim tempService As ServiceController
installedServices = ServiceController.GetServices
For Each tempService In installedServices
If UCase(tempService.ServiceName) = UCase(strMyService) Then
'blnIsServiceInstalled = true
m_svc = tempService
IsInstalled = True
End If
Next
End Function
Private Property ServiceStartupType() As ServiceStartMode
Get
Dim RegValue As ServiceStartMode
Dim RegKey As RegistryKey
RegKey =
Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentC ontrolSet\\Services\\" &
strMyService)
If Not (RegKey Is Nothing) Then
RegValue = CType(RegKey.GetValue("Start"), ServiceStartMode)
RegKey.Close()
RegKey = Nothing
Return RegValue
Else
Return ServiceStartMode.Disabled
End If
End Get
Set(ByVal value As ServiceStartMode)
Dim RegKey As RegistryKey
RegKey =
Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentC ontrolSet\\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",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Set
End Property
Private Sub EvaluateStartupType()
'Startup Type
Select Case ServiceStartupType
Case ServiceStartMode.Automatic
lblStartupType.Text = "Automatic"
pnlStartupType.Blend = New BlendFill(BlendStyle.BackwardDiagonal,
Color.Green, Color.White)
Case ServiceStartMode.Manual
lblStartupType.Text = "Manual"
pnlStartupType.Blend = New BlendFill(BlendStyle.BackwardDiagonal,
Color.Orange, Color.White)
Case Else
lblStartupType.Text = "Disabled"
pnlStartupType.Blend = New BlendFill(BlendStyle.BackwardDiagonal,
Color.Red, Color.White)
End Select
End Sub
Private Sub EvaluateStatus()
'Status
Select Case m_svc.Status
Case ServiceControllerStatus.ContinuePending
lblStatus.Text = "Continue Pending"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Green,
Color.White)
Case ServiceControllerStatus.Paused
lblStatus.Text = "Paused"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Orange,
Color.White)
Case ServiceControllerStatus.PausePending
lblStatus.Text = "Pause Pending"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Orange,
Color.White)
Case ServiceControllerStatus.Running
lblStatus.Text = "Started"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Green,
Color.White)
Case ServiceControllerStatus.StartPending
lblStatus.Text = "Start Pending"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Green,
Color.White)
Case ServiceControllerStatus.StopPending
lblStatus.Text = "Stop Pending"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
Case Else
lblStatus.Text = "Stopped"
pnlStatus.Blend = New BlendFill(BlendStyle.BackwardDiagonal, Color.Red,
Color.White)
End Select
End Sub
Private Sub btnStartupType_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStartupType.Click
Select Case ServiceStartupType
Case ServiceStartMode.Automatic
ServiceStartupType = ServiceStartMode.Manual
Case ServiceStartMode.Manual
ServiceStartupType = ServiceStartMode.Disabled
Case Else
ServiceStartupType = ServiceStartMode.Automatic
End Select
EvaluateStartupType()
End Sub
Private Sub tmrRefresh_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles tmrRefresh.Elapsed
FillValues()
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStart.Click
Try
m_svc.Start()
EvaluateStatus()
Catch ex As Exception
MessageBox.Show("Excepction occured while Starting Service", "Service
Controller", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStop.Click
Try
m_svc.Stop()
EvaluateStatus()
Catch ex As Exception
MessageBox.Show("Excepction occured while Stopping Service", "Service
Controller", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Sub
Private Sub btnPauze_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPauze.Click
Try
m_svc.Pause()
EvaluateStatus()
Catch ex As Exception
MessageBox.Show("Excepction occured while Pausing Service", "Service
Controller", MessageBoxButtons.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.StartInfo.UseShellExecute = True
prcLogin.StartInfo.RedirectStandardOutput = False
prcLogin.StartInfo.FileName = strName
prcLogin.StartInfo.Arguments = strArg
prcLogin.Start()
prcLogin.Close()
End Sub
Private Sub btnInstall_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnInstall.Click
Dim sArgs As String
If btnInstall.Text = "Install" Then
sArgs = " /name=""" & lblService.Text & """ """ &
ConfigurationSettings.AppSettings.Get("MyServicePa th") & """"
RunExe(ConfigurationSettings.AppSettings.Get("Inst allUtil"), sArgs)
Else
sArgs = " /U /name=""" & lblService.Text & """ """ &
ConfigurationSettings.AppSettings.Get("MyServicePa th") & """"
RunExe(ConfigurationSettings.AppSettings.Get("Inst allUtil"), sArgs)
End If
EvaluateInstalled()
End Sub
End Class
'*** THE frmController.Designer.vb-file**
Partial Public Class frmController
Inherits System.Windows.Forms.Form
<System.Diagnostics.DebuggerNonUserCode()_
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
End Sub
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()_
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
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.
<System.Diagnostics.DebuggerStepThrough()_
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New
System.ComponentModel.ComponentResourceManager(Get Type(frmController))
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.BlendPanel
Me.lblStatus = New System.Windows.Forms.Label
Me.lblStartupType = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.lblService = New System.Windows.Forms.Label
Me.pnlStartupType = New VbPowerPack.BlendPanel
Me.pnlInstalled = New VbPowerPack.BlendPanel
Me.pnlSoftware = New VbPowerPack.BlendPanel
Me.btnStartupType = 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.SuspendLayout()
Me.pnlStartupType.SuspendLayout()
Me.pnlInstalled.SuspendLayout()
Me.pnlSoftware.SuspendLayout()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(44, 77)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(78, 17)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Application :"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(44, 127)
Me.Label2.Margin = New System.Windows.Forms.Padding(3, 3, 3, 1)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(62, 17)
Me.Label2.TabIndex = 3
Me.Label2.Text = "Installed :"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(44, 177)
Me.Label3.Margin = New System.Windows.Forms.Padding(3, 1, 3, 3)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(89, 17)
Me.Label3.TabIndex = 4
Me.Label3.Text = "Startup Type :"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(44, 227)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(50, 17)
Me.Label4.TabIndex = 5
Me.Label4.Text = "Status :"
'
'lblSoftware
'
Me.lblSoftware.AutoSize = True
Me.lblSoftware.BackColor = System.Drawing.Color.Transparent
Me.lblSoftware.Font = New System.Drawing.Font("Microsoft Sans Serif",
9.75!, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblSoftware.Location = New System.Drawing.Point(4, 3)
Me.lblSoftware.Name = "lblSoftware"
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.Transparent
Me.lblInstalled.Font = New System.Drawing.Font("Microsoft Sans Serif",
9.75!, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblInstalled.Location = New System.Drawing.Point(4, 3)
Me.lblInstalled.Name = "lblInstalled"
Me.lblInstalled.Size = New System.Drawing.Size(79, 17)
Me.lblInstalled.TabIndex = 0
Me.lblInstalled.Text = "Not Installed"
'
'pnlStatus
'
Me.pnlStatus.Blend = New
VbPowerPack.BlendFill(VbPowerPack.BlendStyle.Backw ardDiagonal,
System.Drawing.Color.Red, System.Drawing.Color.White)
Me.pnlStatus.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pnlStatus.Controls.Add(Me.lblStatus)
Me.pnlStatus.Location = New System.Drawing.Point(155, 222)
Me.pnlStatus.Name = "pnlStatus"
Me.pnlStatus.Size = New System.Drawing.Size(182, 27)
Me.pnlStatus.TabIndex = 7
Me.pnlStatus.Tag = ""
'
'lblStatus
'
Me.lblStatus.AutoSize = True
Me.lblStatus.BackColor = System.Drawing.Color.Transparent
Me.lblStatus.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.lblStatus.Location = New System.Drawing.Point(4, 3)
Me.lblStatus.Name = "lblStatus"
Me.lblStatus.Size = New System.Drawing.Size(55, 17)
Me.lblStatus.TabIndex = 0
Me.lblStatus.Text = "Stopped"
'
'lblStartupType
'
Me.lblStartupType.AutoSize = True
Me.lblStartupType.BackColor = System.Drawing.Color.Transparent
Me.lblStartupType.Font = New System.Drawing.Font("Microsoft Sans Serif",
9.75!, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblStartupType.Location = New System.Drawing.Point(4, 3)
Me.lblStartupType.Name = "lblStartupType"
Me.lblStartupType.Size = New System.Drawing.Size(57, 17)
Me.lblStartupType.TabIndex = 0
Me.lblStartupType.Text = "Disabled"
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label5.Location = New System.Drawing.Point(44, 27)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(57, 17)
Me.Label5.TabIndex = 10
Me.Label5.Text = "Service :"
'
'lblService
'
Me.lblService.AutoSize = True
Me.lblService.BackColor = System.Drawing.Color.Transparent
Me.lblService.Font = New System.Drawing.Font("Microsoft Sans Serif",
9.75!, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblService.Location = New System.Drawing.Point(161, 27)
Me.lblService.Name = "lblService"
Me.lblService.Size = New System.Drawing.Size(67, 17)
Me.lblService.TabIndex = 9
Me.lblService.Text = "MyService"
'
'pnlStartupType
'
Me.pnlStartupType.Blend = New
VbPowerPack.BlendFill(VbPowerPack.BlendStyle.Backw ardDiagonal,
System.Drawing.Color.Red, System.Drawing.Color.White)
Me.pnlStartupType.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pnlStartupType.Controls.Add(Me.lblStartupType)
Me.pnlStartupType.Location = New System.Drawing.Point(155, 172)
Me.pnlStartupType.Name = "pnlStartupType"
Me.pnlStartupType.Size = New System.Drawing.Size(182, 27)
Me.pnlStartupType.TabIndex = 8
Me.pnlStartupType.Tag = ""
'
'pnlInstalled
'
Me.pnlInstalled.Blend = New
VbPowerPack.BlendFill(VbPowerPack.BlendStyle.Backw ardDiagonal,
System.Drawing.Color.Red, System.Drawing.Color.White)
Me.pnlInstalled.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pnlInstalled.Controls.Add(Me.lblInstalled)
Me.pnlInstalled.Location = New System.Drawing.Point(155, 122)
Me.pnlInstalled.Name = "pnlInstalled"
Me.pnlInstalled.Size = New System.Drawing.Size(182, 27)
Me.pnlInstalled.TabIndex = 6
Me.pnlInstalled.Tag = ""
'
'pnlSoftware
'
Me.pnlSoftware.Blend = New
VbPowerPack.BlendFill(VbPowerPack.BlendStyle.Backw ardDiagonal,
System.Drawing.Color.Red, System.Drawing.Color.White)
Me.pnlSoftware.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pnlSoftware.Controls.Add(Me.lblSoftware)
Me.pnlSoftware.Location = New System.Drawing.Point(155, 72)
Me.pnlSoftware.Name = "pnlSoftware"
Me.pnlSoftware.Size = New System.Drawing.Size(182, 27)
Me.pnlSoftware.TabIndex = 1
Me.pnlSoftware.Tag = ""
'
'btnStartupType
'
Me.btnStartupType.Location = New System.Drawing.Point(353, 177)
Me.btnStartupType.Name = "btnStartupType"
Me.btnStartupType.Size = New System.Drawing.Size(52, 22)
Me.btnStartupType.TabIndex = 12
Me.btnStartupType.Text = "Change"
'
'btnStart
'
Me.btnStart.Location = New System.Drawing.Point(353, 227)
Me.btnStart.Name = "btnStart"
Me.btnStart.Size = New System.Drawing.Size(52, 22)
Me.btnStart.TabIndex = 13
Me.btnStart.Text = "Start"
'
'btnStop
'
Me.btnStop.Location = New System.Drawing.Point(412, 227)
Me.btnStop.Name = "btnStop"
Me.btnStop.Size = New System.Drawing.Size(52, 22)
Me.btnStop.TabIndex = 14
Me.btnStop.Text = "Stop"
'
'btnPauze
'
Me.btnPauze.Location = New System.Drawing.Point(471, 227)
Me.btnPauze.Name = "btnPauze"
Me.btnPauze.Size = New System.Drawing.Size(52, 22)
Me.btnPauze.TabIndex = 15
Me.btnPauze.Text = "Pauze"
'
'btnInstall
'
Me.btnInstall.Location = New System.Drawing.Point(353, 127)
Me.btnInstall.Name = "btnInstall"
Me.btnInstall.Size = New System.Drawing.Size(52, 22)
Me.btnInstall.TabIndex = 16
Me.btnInstall.Text = "Install"
'
'frmController
'
Me.AutoScaleBaseSize = 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.btnStartupType)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.lblService)
Me.Controls.Add(Me.pnlStartupType)
Me.Controls.Add(Me.pnlStatus)
Me.Controls.Add(Me.pnlInstalled)
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("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmController"
Me.Text = "SMS Server Service Controller"
Me.pnlStatus.ResumeLayout(False)
Me.pnlStatus.PerformLayout()
Me.pnlStartupType.ResumeLayout(False)
Me.pnlStartupType.PerformLayout()
Me.pnlInstalled.ResumeLayout(False)
Me.pnlInstalled.PerformLayout()
Me.pnlSoftware.ResumeLayout(False)
Me.pnlSoftware.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
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.BlendPanel
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.BlendPanel
Friend WithEvents pnlInstalled As VbPowerPack.BlendPanel
Friend WithEvents pnlSoftware As VbPowerPack.BlendPanel
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" ?>
<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log
in Windows Forms projects.-->
<source name="Microsoft.VisualBasic.MyServices.Log.Windows FormsSource"
switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="System.Diagnostics.FileLogTraceListener, Microsoft.VisualBasic,
Version=8.0.1200.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the
name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener"
initializeData="APPLICATION_NAME"/-->
</sharedListeners>
</system.diagnostics>
<appSettings>
<add key="MyService" value="SMS Service"></add>
<add key="MyServicePath" value="C:\Program Files\SMS Server\SMS
Service.exe"></add>
<add key="Application" value=""></add>
<add key="InstallUtil"
value="C:\WINNT\Microsoft.NET\Framework\v2.0.40607 \InstallUtil.exe"></add>
</appSettings>
</configuration>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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:
...
|
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...
|
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...
|
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.
...
|
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...
|
by: Joris De Groote |
last post by:
Hi,
can vb check if a windows service is running or not? ( Webclient )
Thanks
Joris
|
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...
|
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?
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |