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