Check if a process is running...

...and if it is, display the result

Page 1 of 1

2 Replies - 4638 Views - Last Post: 27 October 2009 - 02:12 AM Rate Topic: -----

#1 eicar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 11-October 09

Check if a process is running...

Posted 26 October 2009 - 03:50 PM

Hi!

Im working on a small virus removal application, and i have a piece of code to check if a process is running,
although, it doesn't seem to work.

The code is as follows:

ListView2.Items.Add(TimeOfDay + " - Starting Process Scanner")
		Dim Vir As Process() = Process.GetProcesses
		Dim a As Integer
		For a = 0 To Vir.Length - 1
			Debug.WriteLine(Vir(a).ProcessName)
			If Strings.UCase(Vir(a).ProcessName) = Strings.UCase("rofl") Then
		
				ListView2.Items.Add(TimeOfDay + " - Virus Process Active")
				Button3.Enabled = True
			Else
				ListView2.Items.Add(TimeOfDay + " - No Virus Process Active")
			End If
		Next
	End Sub


The process name is "rofl.exe", i also had an application running with that process name.
Nothing happened with the process, allthough it jammed my listview full with "no virus process active"
messages.

Could anyone explain why this wont work, and point me in the right direction?

This post has been edited by eicar: 26 October 2009 - 03:56 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Check if a process is running...

#2 dzone41  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 216
  • Joined: 21-August 09

Re: Check if a process is running...

Posted 26 October 2009 - 05:04 PM

I tried your code and it works fine for me, I replaced "TimeOfDay" with Vir(a).ProcessName so I could see the names of the processes, I used a process called smss, and it showed the correct statement for the one process match and the other statement for all the others.
I did put the output into a listbox instead of a ListView because it was a little quicker at the time.

This post has been edited by dzone41: 26 October 2009 - 05:05 PM

Was This Post Helpful? 0
  • +
  • -

#3 eicar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 11-October 09

Re: Check if a process is running...

Posted 27 October 2009 - 02:12 AM

Thank you! I got it to work now, even the killing process part.
Now, if its not to much, there is some other problems i have. I believe
they are not so hard to solve, allthough i haven't found out anything on how to do it.

1) Every child node in my treeview gets the same icon.
Posted Image
I've looked around and trying to find a solution, but didn't find anything.

And, im using the following code to "navigate" the application:

If e.Node.Name = "Node1" Then
			Panel1.Show()
			Timer1.Start()
			Label4.Text = Date.Today
		ElseIf e.Node.Name = "Node10" Then
			Timer1.Stop()
			Panel1.Visible = False
			Panel2.Visible = False
			Panel3.Visible = False
		ElseIf e.Node.Name = "Node3" Then
			Timer1.Stop()
			Panel2.Visible = True
			Panel1.Visible = False
			Panel3.Visible = False
		ElseIf e.Node.Name = "Node9" Then
			Timer1.Stop()
			Panel3.Visible = True
			'Panel3.BringToFront()
		End If


And when i press node9, nothing happens [Process Control]. I have to press Node3 [Infection Control] first.

Sorry if i am asking for too much.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1