• We just launched and are currently in beta. Join us as we build and grow the community.

Start and Kill Process using VB.NET

Disayang

Lead Magnet Creator
D Rep
0
0
0
Rep
0
D Vouches
0
0
0
Vouches
0
Posts
128
Likes
46
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
This is my other tutorial in VB.NET that start and kill a process or a program. This is not by means of killing someone. haha. LOL :)

Starting a process or calling an application is just simple here in vb.net. Just only add this syntax System.

Diagnostics

.

Process

.

Start

(

"This is the process that you are going to start"

)

Take note that starting and opening a process is just the same.

Now, let's start this Start and Kill Process tutorial!

1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.

2. Next, add two Buttons named Button1 labeled as "Start Notepad" and Button2 labeled as "Kill Notepad". You must design your layout like this:
design_4.png


3. Next, put this code in the Button1_Click. This is to open and start your Notepad.
  1. Private

    Sub

    Button1_Click(

    ByVal

    sender As

    System.

    Object

    , ByVal

    e As

    System.

    EventArgs

    )

    Handles

    Button1.

    Click
  2. System.

    Diagnostics

    .

    Process

    .

    Start

    (

    "notepad"

    )
  3. End

    Sub

System.

Diagnostics

.

Process

.

Start

(

"notepad"

)

- a syntax used to open your notepad. Take note that you can change any process as long as you have that syntax.

Testing:

clicknotepad.png


4. Now, code for Button2_Click. This button is killing all the process that has the Notepad Application.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim _proceses As Process()
_proceses = Process.GetProcessesByName("notepad")
For Each proces As Process In _proceses
proces.Kill()
Next
MsgBox("Notepad process killed!")
End Sub

The GetProcessesByName(

String

)

syntax here creates an array of new Process components and associates them with all the process resources on the local computer that share the specified process name. So meaning it will kill all the Notepad Process as we have this code
  1. For

    Each

    proces As

    Process In

    _proceses
  2. proces.

    Kill

    (

    )
  3. Next

After killing or closing the Notepad, it will prompt the user "Notepad process killed!"

Testing:

output_0.png


Download the source code below and try it! :)

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.

Best Regards,

Engr. Lyndon R. Bermoy

IT Instructor/System Developer/Android Developer

Mobile: 09079373999

Telephone: 826-9296

E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,526

323,535

Top