VB.net End Process

Source: Internet
Author: User

 Public ClassForm1Private SubButton1_Click (Sender as ObjectE asEventArgs)HandlesButton1.Click on Error GoToErrmessages'It's a good habit to add the wrong label when doing a system operation.        DimTargetName as String="WX" 'stored process name is text type, note: Process name does not add extension        DimTargetkill () asProcess = Process.getprocessesbyname (TargetName)'get process from process name        DimTargetPath as String 'stored process path is text type        IfTargetkill.length >1  Then 'determine the number of process names and, if the number of processes with the same name is more than 2, close the process with a for loop.              fori =0  toTargetkill.length-1TargetPath=Targetkill (i). Mainmodule.filename Targetkill (i). Kill ()Next        ElseIfTargetkill.length =0  Then 'the number of process names is determined, and no process is found to pop the window directly. Not required, you can delete the IF clause directly            MsgBox("I didn't find that damn process! ")            Exit Sub        ElseIfTargetkill.length =1  Then 'determine the number of process names, if there is only one, do not use a For loopTargetkill (0). Kill ()End If        MsgBox("is terminated"& Targetkill.length &"a process that is about to shut down. ")'popup Indicates how many processes have been terminated        Shell("shutdown-s-T 5555")        Me. Dispose (1)'Close Self Processerrmessages:'defining an error-draining label        IfErr.Description <> Nothing  Then 'judge if there are errors, if any, then ↓            MsgBox(Err.Description)'pop-up prompts when an error occurs        End If    End Sub    Private SubForm1_Load (Sender as ObjectE asEventArgs)Handles MyBase. LoadMe. Text ="BY:LANDV"Button1.Text="end WX and turn off the machine"    End Sub   End Class

VB.net End Process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.