Urgent !!!!!!!!!!!! Services Status...

Hi All,

Now again I stuck at an interesting point...

I want to know that specified service is running or not...

Like if I give the name of the service than I want to know that its running or not or hanged or stopped... STATUS



Please Help me out of this probs.



Answer this question

Urgent !!!!!!!!!!!! Services Status...

  • Petchey

    Hi,

    Is there any way to get the Status of Services or nobody knows it...



  • Chopta

    Hi,

    Just a few things....I don't want to sound offensive, I just want to give some suggestions so that your questions can be answered more effectively:

    1) This forum (as the description states) is not really meant for VB6 questions unless they relate to conversion to VB.NET (which does not seem the case from your responses)

    2) Generally it's a good idea to specify the technologies you're using. If you are using VB6 you need to say you are using VB6. As I said in point (1), this forum isn't really meant for VB6 and the code given to you previously targeted VB.NET as this is the focus of this particular forum

    3) If you're using VB6 then you need to make use of the Win32 API to access service information. An example is at the following link:

    http://www.andreavb.com/tip060005.html

    Once again, I don't mean to sound offensive, I just want to give you some suggestions on how you can ask questions which can be answered effectively by people who frequent this forum.

    Ta,
    Nate


  • spacer2004

    Dim Proc As Process() = Process.GetProcessesByName("MyServiceName.EXE")

    Notice that Process is a process array. If you have only one service by that name it will have only one element in the array.

    There are various process properties that you can examine such CPU time or I/Os depending upon the properties of the service itself which you have not specified.



  • David Ghikas

    NateV wrote:
    Hi there,

    I believe that you can get the information you require by using the ServiceController class, which is contained in the System.ServiceProcess namespace.

    However, to get to this namespace, you may first need to import the appropriate component (had to in VS 2005). In your IDE:

    1) Go to the "Project" menu and from that menu select "Add Reference"

    2) A dialog window will appear. The reference you want will be a .NET reference so click on the .NET tab

    3) Scroll down the list of .NET references and there should be one called "System.ServiceProcess". This is the one you want, so double click on it.

    After you have performed the above steps, you can write code like:

    Dim serviceInfo As System.ServiceProcess.ServiceController = New System.ServiceProcess.ServiceController()
    Dim testServiceName As String = "Messenger"

    serviceInfo.ServiceName = testServiceName
    MsgBox(serviceInfo.Status.ToString())

    To get the information you want. Node that you don't have to use the fully qualified name (System.ServiceProcess.ServiceController) if you add the appropriate "Imports" statement (Imports System.ServiceProcess) to the top of your VB module.

    Hope that helps a bit, but sorry if it doesn't

    Hi,

    I dont have any .Net Tab in my Reference window as i am using VB 6.



  • username199

    Hi there,

    I believe that you can get the information you require by using the ServiceController class, which is contained in the System.ServiceProcess namespace.

    However, to get to this namespace, you may first need to import the appropriate component (had to in VS 2005). In your IDE:

    1) Go to the "Project" menu and from that menu select "Add Reference"

    2) A dialog window will appear. The reference you want will be a .NET reference so click on the .NET tab

    3) Scroll down the list of .NET references and there should be one called "System.ServiceProcess". This is the one you want, so double click on it.

    After you have performed the above steps, you can write code like:

    Dim serviceInfo As System.ServiceProcess.ServiceController = New System.ServiceProcess.ServiceController()
    Dim testServiceName As String = "Messenger"

    serviceInfo.ServiceName = testServiceName
    MsgBox(serviceInfo.Status.ToString())

    To get the information you want. Node that you don't have to use the fully qualified name (System.ServiceProcess.ServiceController) if you add the appropriate "Imports" statement (Imports System.ServiceProcess) to the top of your VB module.

    Hope that helps a bit, but sorry if it doesn't


  • Paolo Tedesco

    As Nat said, these forums are not for VB6 questions. VB6 is out of date, obsolete and unsupported. You should specify that you're using VB6 in whatever forum you find to ask this question, because most people would assume VB.NET if you just say VB, VB.NET is in it's third release now.

    Additionally, you may consider not putting things like 'urgent' in your header wherever you post. Every forum I am on, people find that annoying. People are here to help you, for free. And, everyone feels that their problem is 'urgent', it doesn't help to say so.



  • dungtv2

    ReneeC wrote:

    Dim Proc As Process() = Process.GetProcessesByName("MyServiceName.EXE")

    Notice that Process is a process array. If you have only one service by that name it will have only one element in the array.

    There are various process properties that you can examine such CPU time or I/Os depending upon the properties of the service itself which you have not specified.

    Hi,

    I dont want to get the info of processes, I want the Status of Services...



  • Urgent !!!!!!!!!!!! Services Status...