Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Process.Start("notepad.exe")
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
' 모두 종료
Do Until Process.GetProcessesByName("notepad").Count < 1
For Each p As Process In Process.GetProcessesByName("notepad")
p.CloseMainWindow()
Next
Loop
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
For Each p As Process In Process.GetProcessesByName("notepad")
p.Kill()
p.Close()
Next
End Sub
Private Sub ListBox_Items()
ListBox1.Items.Clear()
For Each p As Process In Process.GetProcesses
If Not ListBox1.Items.Contains(p.ProcessName) Then
ListBox1.Items.Add(p.ProcessName)
End If
Next
ListBox1.Sorted = True
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ListBox_Items()
End Sub
End Class
Dim ProcID As Integer
Dim NOTEPADtemp As String = "NOTEPAD.EXE c:\aa.txt"
ProcID = Shell(NOTEPADtemp, AppWinStyle.NormalFocus)
AppActivate(ProcID)
SendKeys.SendWait(ProcID)
Dim aProcess As System.Diagnostics.Process
aProcess = System.Diagnostics.Process.GetProcessById(ProcID)
aProcess.Kill()
이 댓글을