Activate a Running Application by Name
'Namespace: Microsoft.VisualBasic
'Application Name: ""NOTEPAD.EXE""
AppActivate("Untitled - Notepad")
Activate a Running Application by Process ID
'Assembly: System.dll
'Namespace: System
'Namespace: Microsoft.VisualBasic
'Application Name: ""NOTEPAD.EXE""
Dim processID As Integer
processID = Shell("NOTEPAD.EXE", AppWinStyle.NormalFocus)
AppActivate(processID)
Write a Message to the Application Log
'Assembly: System.dll
'Namespace: System
'Namespace: Microsoft.VisualBasic
'Message: "Critical Error!"
My.Application.Log.WriteEntry("Critical Error")
Stop an Application
'Namespace: Microsoft.VisualBasic
'Namespace: System.Diagnostics
'Application: "Notepad.exe"
For Each proc As Process In Process.GetProcessesByName("Notepad.exe")
proc.CloseMainWindow()
Next
Read Command Line Arguments
'Namespace: Microsoft.VisualBasic
For Each argument As String In My.Application.CommandLineArgs
'do something with argument
Next
Make an Asynchronous Method Call
'Namespace: Microsoft.VisualBasic
'Namespace: System.Threading
Private Sub startBackgroundTask()
' Execute the Background Task
backgroundWorkerInstance.RunWorkerAsync()
End Sub
Private Sub backgroundWorkerInstance_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles backgroundWorkerInstance.DoWork
' This method will execute in the background thread created by the BackgroundWorker componet
End Sub
Private Sub backgroundWorkerInstance_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles backgroundWorkerInstance.RunWorkerCompleted
' This event fires when the DoWork event completes
End Sub