|
-
Jan 24th, 2011, 01:28 PM
#1
Thread Starter
New Member
need help please
hi
so i got another problem that i tried many many many time to fix.
each way i try give same result.
( msgbox is for test purpose )
this result is whatever i type after !kill is shown in the msgbox that mean this part is right but it dont kill any process
here my code
Code:
If inputLine.Contains("!kill") Then
Try
Dim killing As Array
killing = inputLine.Split(" ")
MsgBox(killing(4))
killProcess(killing(4))
Catch d As Exception
IRCwriter.Flush()
End Try
End If
and here the function
Code:
Public Sub killProcess(ByRef strProcessToKill As String)
Dim proc() As Process = Process.GetProcesses
For i As Integer = 0 To proc.GetUpperBound(0)
If proc(i).ProcessName = strProcessToKill Then
proc(i).Kill()
End If
Next
End Sub
Code:
Public Sub killProcess(ByRef strProcessToKill As String)
Dim proc() As Process = Process.GetProcesses
For i As Integer = 0 To proc.GetUpperBound(0)
If proc(i).ProcessName = strProcessToKill Then
proc(i).Kill()
End If
Next
End Sub
i get no error at all it just wont kill the process i type
i also tried a new project with a textbox but still wont work
any idea ? ( i tried many way on the web )
thanks
-
Jan 24th, 2011, 02:46 PM
#2
Re: need help please
Welcome to the forum! 
Instead of going through all the processes list you could use the GetProcessesByName() method.
Also, have you made sure that there is actually a process with a ProcessName that matches the one you pass to your killProcess method? You could put a breakpoint inside your For loop and add proc(i).ProcessName to your watch list and check that out.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Jan 24th, 2011, 04:51 PM
#3
Thread Starter
New Member
Re: need help please
 Originally Posted by stlaural
Welcome to the forum!
Instead of going through all the processes list you could use the GetProcessesByName() method.
Also, have you made sure that there is actually a process with a ProcessName that matches the one you pass to your killProcess method? You could put a breakpoint inside your For loop and add proc(i).ProcessName to your watch list and check that out.
thanks for your reply.
GetProcessBtName() dosnt work too.
and yes i try to kill firefox.exe wich is open ( also tried with msnmsgr.exe ) but none work.
-
Jan 24th, 2011, 06:03 PM
#4
Re: need help please
Here, I wrote this very small console app in vb.net, it works perfectly for me on Windows 7. As you will notice, it displays all the process names and I am closing the one named "firefox". So as I suggested, maybe you simply didn't use the right name and that is why I suggested to have a lood at the content of process array proc(). 
vb.net Code:
Sub Main()
Dim proc() As Process = Process.GetProcesses
For i As Integer = 0 To proc.GetUpperBound(0)
Console.WriteLine(proc(i).ProcessName)
If proc(i).ProcessName = "firefox" Then
proc(i).Kill()
End If
Next
Console.ReadLine()
End Sub
Which also means that GetProcessesByName() should work if you enter an existing processName.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Jan 24th, 2011, 07:59 PM
#5
Thread Starter
New Member
Re: need help please
thank you very much it work now 
so now i can work on ping
thanks
-
Jan 24th, 2011, 08:25 PM
#6
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Jan 24th, 2011, 09:12 PM
#7
Thread Starter
New Member
Re: need help please
another question. is it possible to convert array to string ?
Code:
If inputLine.Contains("!ping") Then
Try
Dim PingIP As Array
PingIP = inputLine.Split(" ")
Shell("ping ", PingIP)
i get an error saying i cant use something array
-
Jan 24th, 2011, 10:11 PM
#8
Re: need help please
As the Split method already returns a string array, your sould start by declaring PingIP as a string array.
not 100% for the syntax though so you better have a look on the web first.
Then as it is an array, you should use a For loop to loop trough all its string elements, and THEN call Shell method for each element.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
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
|