新建From1(窗体),新建Command1-2(按钮CommandButton),代码:
Dim pid As Double
Private Sub Command1_Click()
pid = Shell("C:\windows\system32\notepad.exe")
End Sub
Private Sub Command2_Click()
Shell ("taskkill /pid " & pid)
End Sub
可以打开记事本,和关闭此记事本。