Imports System Imports Microsoft Imports System.Diagnostics Module Module1 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub Main() ' proc.Responding(arg) Dim Sendkeys As Windows.Forms.SendKeys Dim path As String = "E:\Program Files\EA Games\Ultima Online sphere\client.exe" Dim arg As String = "client" Dim proc As Process Dim procs() As Process = Process.GetProcessesByName(arg) If procs.Length = 1 Then Console.WriteLine("found") proc = procs(0) ElseIf procs.Length > 1 Then Console.WriteLine _ ("Process name is ambiguous. Unable to proceed.") End ElseIf procs.Length = 0 Then Console.WriteLine("Process not found. Unable to proceed") Process.Start(path) Sleep(5000) AppActivate("euox") Sendkeys.SendWait("{F9}") End End If ' kill the process Dim res As Boolean ' attempt to kill the process by closing its main window res = proc.CloseMainWindow() If res = False Then ' no UI or the window is disabled proc.Kill() End If ' wait for the process to end If proc.WaitForExit(5000) Then Console.WriteLine("Process {0} has been killed", proc.ProcessName) Else Console.WriteLine("Unable to kill process {0}", proc.ProcessName) End If Console.WriteLine("complete") Sleep(2000) Process.Start(path) Sleep(5000) AppActivate("euox") Sendkeys.SendWait("{F9}") End Sub End Module