vb.netskype4com

How to determine if particular process is running


I am building an application to change my Skype status to busy whenever a particular program is being run. I tried the following code:

Private Sub WaitTimer_Tick(sender As Object, e As EventArgs) Handles WaitTimer.Tick
        For Each Me.Process In Process.GetProcesses(My.Computer.Name)
            On Error Resume Next
            If Process.ProcessName = Process.ProcessName = "SCII" Then
                skype.Changeuserstatus(TUserStatus.cusAway)
                Button1.Text = "SCII is running"
                Exit Sub
            End If
        Next
        Button1.Text = "SCII is not running"
    End Sub

Whenever I run this, it always says SCII is open while it is not. What am I doing wrong? Is there a better more efficient way for checking on running processes other then a timer?

As a side note, I Import Skype4COMLib.


Solution

  • This is the problem :

    If Process.ProcessName = Process.ProcessName = "SCII" Then
    

    It should be :

    If Process.ProcessName = "SCII" Then