Run Notepad

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows フォーム デザイナで生成されたコード "

Public Sub New()
MyBase.New()

' この呼び出しは Windows フォーム デザイナで必要です。
InitializeComponent()

' InitializeComponent() 呼び出しの後に初期化を追加します。

End Sub

' Form は dispose をオーバーライドしてコンポーネント一覧を消去します。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

' Windows フォーム デザイナで必要です。
Private components As System.ComponentModel.IContainer

' メモ : 以下のプロシージャは、Windows フォーム デザイナで必要です。
' Windows フォーム デザイナを使って変更してください。
' コード エディタは使用しないでください。
Friend WithEvents Button1 As System.Windows.Forms.Button
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(88, 56)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim intProcID As Integer

Try
intProcID = Shell("NOTEPAD.EXE", AppWinStyle.NormalFocus)

AppActivate(intProcID)
SendKeys.SendWait(ControlChars.NewLine)
SendKeys.SendWait("test test test")

Catch ex As IO.FileNotFoundException
MessageBox.Show(ex.Message)

End Try
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class