Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

terminate a process (Vb.NET 1.1)

Posted on 2006-06-30
2
Medium Priority
?
1,755 Views
Last Modified: 2008-07-05
Hi!

Given the process Id, how can I forcefully terminate a process? I tried Process.GetProcessById(id).Kill(), but i get an "Access Denied" exception for a number of processes, even though I can terminate them via Task Manager.

Thanks,
muskad202
0
Comment
Question by:muskad202
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:king_villy
ID: 17022421
Use this code , by using this code you can terminate Process by name , by id both of style s
hope it will help you


========================================
public Sub Terminator_Sub

Dim target_hwnd, target_process_id, target_process_handle As Integer

        ' Get the target's window handle.
        target_hwnd = FindWindow(vbNullString, "Name of Terminated Process")
        If (target_hwnd = 0) Then
            MessageBox.Show("Error finding target window handle")
            Exit Sub
        End If

        ' Get the process ID.
        target_process_id = 0
        GetWindowThreadProcessId(target_hwnd, target_process_id)
        If (target_process_id = 0) Then
            MessageBox.Show("Error finding target process ID")
            Exit Sub
        End If

        ' Open the process.
        target_process_handle = OpenProcess( _
            SYNCHRONIZE Or PROCESS_TERMINATE, _
            0, target_process_id)

        If (target_process_handle = 0) Then
            MessageBox.Show("Error finding target process handle")
            Exit Sub
        End If

        ' Terminate the process.
        If (TerminateProcess(target_process_handle, 2) = 0) Then
            MessageBox.Show("Error terminating process")
        Else
            MessageBox.Show("Process terminated")
        End If

        ' Close the process.
        CloseHandle(target_process_handle)
End Sub
0
 
LVL 8

Accepted Solution

by:
kaliyugkaarjun earned 120 total points
ID: 17022807
HEre is a link showing example of how to terminate a process in  VB.net ...just go thr it.

http://www.vb-helper.com/howto_net_terminate_process.html
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question