Results 1 to 8 of 8

Thread: need help please

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    4

    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

  2. #2
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    4

    Re: need help please

    Quote Originally Posted by stlaural View Post
    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.

  4. #4
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    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:
    1. Sub Main()
    2.         Dim proc() As Process = Process.GetProcesses
    3.         For i As Integer = 0 To proc.GetUpperBound(0)
    4.             Console.WriteLine(proc(i).ProcessName)
    5.             If proc(i).ProcessName = "firefox" Then
    6.                 proc(i).Kill()
    7.             End If
    8.         Next
    9.         Console.ReadLine()
    10.     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

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    4

    Re: need help please

    thank you very much it work now

    so now i can work on ping

    thanks

  6. #6
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: need help please

    You're welcome!
    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

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    4

    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

  8. #8
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: need help please

    As the Split method already returns a string array, your sould start by declaring PingIP as a string array.
    vb.net Code:
    1. Dim PingIP As String()
    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
  •  



Click Here to Expand Forum to Full Width