|
-
May 27th, 2003, 12:23 PM
#1
Thread Starter
Lively Member
check if a service is runing
Hi all
I use pcanywhere to remote pooling for a few stores,
the problem is when pcanywhere is not waiting for a connection,
pcanywhere wait host is a service and it runs a exe,
the service executable path is C:\Program Files\Symantec\pcAnywhere\awhost32.exe
I cant just shell it because maybe its running,
is there a way in vb.net to check if the service is running if not start it?
Thank You
-
May 27th, 2003, 02:22 PM
#2
I wonder how many charact
Funny...
Wouldn't PCAnywhere check to see if an instance of itself was already running?
-
May 27th, 2003, 03:41 PM
#3
Addicted Member
This is cut from my project. Let me know if you need anything else.
PHP Code:
Private myService As ServiceController ' Used as a reference to the service
...
Private Sub CheckServiceInstallation()
' Verify to see if the service is installed.
Dim installedServices() As ServiceController
Dim tmpService As ServiceController
Dim i As Integer = 0
installedServices = ServiceController.GetServices()
For Each tmpService In installedServices
If tmpService.DisplayName = "YOUR SERVICE NAME" Then
isServiceInstalled = True
' Assign the service to myService, so we can use it later.
myService = tmpService
Exit For
End If
Next tmpService
msgbox("Service Status: " + myService.Status.ToString())
End Sub
Last edited by Shurijo; May 27th, 2003 at 05:02 PM.
-Shurijo
-
May 27th, 2003, 06:05 PM
#4
Thread Starter
Lively Member
Hi Shurijo
Thanks for your code
i have one problem,
Private myService As ServiceController
ServiceController is not declared?
Thanks for your help
-
May 28th, 2003, 02:20 PM
#5
Fanatic Member
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbtskCreatingServiceControllerComponentInstances.htm
VB Code:
[b]
Imports System
Imports System.ServiceProcess
Imports System.Diagnostics
[/b]
Module Module1
Sub Main()
Dim myController As New ServiceController("IISAdmin")
If myController.CanStop Then
Debug.WriteLine(myController.ServiceName & " can be stopped.")
Else
Debug.WriteLine(myController.ServiceName & " cannot stop.")
End If
End Sub
End Module
-
May 28th, 2003, 03:10 PM
#6
Thread Starter
Lively Member
Thank you
i have one problem,
System.ServiceProcess
vs.net namesoace or type can't be found?
thanks again
Last edited by cgj; May 28th, 2003 at 08:52 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|