?
Solved

terminate a process (Vb.NET 1.1)

Posted on 2006-06-30
2
Medium Priority
?
1,754 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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