Followers

Follow by Email

Cloud Labels

[Fixing] Report Viewer control toolbar in Google Chrome [Solved] How to kill any process using VB.NET ABAP Admin Panel Template adonet Affiliate site Airline Reservation System Project in PHP Ajax Android androidstudio AngularJS aspnet Big Data Blogger Bookmarking Bootstrap 4 C# C#.Net How To: Send email in asp.net using c# cloud computing Computer Programming CRYSTALREPORTS CSS Databases and ADO.NET DevOps Django dotnet E-commerce Website Php MySQL source code free download Employee Leave Management System in PHP/MySql with Full Source Code Firebase Free Sourcecode in PHP Free Asp.net SourceCode Free SourceCode in C# FreeSourcecode FreeSourcecodevb.net FreeSourcecodinPHP fullform google Google Fuchsia Hospital Management System with C# with Full Source Code How To Assign a Value to a Variable in Python How to Bind Data to Repeater Control in Asp.net How to generate QR Code in C# windows application HOW TO GENERATE RANDOM NUMBER IN C# how to ping ip address in asp net How To Read A Text File In C# How to Use Anchoring Controls In visual c#.net How To Using LINQ to SQL Classes With Example HTML HTML Head Title Access Denied Image Submission Sites introduction to csharp programming JavaProject javascript jQuery Library Management System Using PHP and MySQL with Full Source Code LINQ LINQ In C#.Net MangoDB Microsoft Mobile Blazor mvc MySQL Nodejs NuGet Online Blood Bank Management System Project Online Class and Exam Scheduling System in PHP PhotoshopCs5 PHP pm mandhan yojana PMYOJANA Project python QR (Quick Response) Code Generator using C#.NET Querying a Database with LINQ to SQL sap SAP Basis And Security SAP ECC 6.0 Installation Step by Step SAPMM SarkariNukari sbi School Fees Payment System in PHP With Source code SearchEngine Site seo SEO Tutorials software sql SQLite StringBuilder Class In C# TechNews Timer ajax control In Asp.net Top Most Popular Social Bookmarking TRICK TIPS VB.NET VB.NET Classes VB.NET Conditional Statements VB.NET Loops vbnet visual studio download What are variables? what is JavaScript? What is Link Building? What is Node.Js? whatsappgb Windows Forms WordPress

Labels

[Solved]How to kill any process using VB.NET

[Solved]How to kill any process using VB.NET,.Net,Close running processes,Get the list of processes,Kill other processes running ,sourcecode net
Share it:

[Solved] How to kill any process using VB.NET


Close running processes

.Net made it very easy for handling processes. It is much easier to close the applications using Process.Kill(). Processes can be iterated using the ‘for each’ loop. The process object taken from enumeration has enough methods and properties to deal with processes.

Get the list of processes

To get the list of instances running with the current application's name, we can use the Process.GetProcessesByName(“ProcessName”). This method returns a collection of processes with the name “ProcessName”. Thereafter accessing each process is easy with a ‘for each’ loop.

Kill other processes running under the same name

I had a requirement to ensure that, the current process is the only running process. The rest of the other instances of the processes have to be closed. Using the GetProcessesByName method we can get the list of current instances. While iterating through the collection, we can identify the current process by the ID property. We can get the current running process by Process.GetCurrentProcess(). Now it is very easy to kill other processes than the current one.

Source code 


Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        For Each RunningProcess In Process.GetProcessesByName("Notepad")
            RunningProcess.Kill()
        Next
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        For Each RunningProcess In Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName)
            If (Not RunningProcess.Id = Process.GetCurrentProcess().Id) Then
                RunningProcess.Kill()
            End If
        Next
    End Sub
End Class

Read Also:-

Share it:

[Solved] How to kill any process using VB.NET

VB.NET

vbnet

Windows Forms

Post A Comment: