Sometimes a developer has to call an EXE from another EXE. While calling EXE there can be a requirement to pass parameter.
Use the following code in the global module to build an EXE which is calling other EXE. Set startup Object to Submain() function.
In the example two parameters are passed from the EXE and calling EXE is capturing them here. Parameters are paased as string seprated by Space " ".
Imports System.Windows.Forms
Module Module1
Public Sub main()
Dim frm As New Form1
Dim str() As String
str = GetCommandLineArgs()
If (UBound(str) >= 0) Then
a = str(0).ToString
b = str(1).ToString
End If
Application.Run(frm)
End Sub
Function GetCommandLineArgs() As String()
' Declare variables.
Dim separators As String = " "
Dim commands As String = Microsoft.VisualBasic.Command()
Dim args() As String = commands.Split(separators.ToCharArray)
Return args
End Function
End Module
Write the following code from where EXE has to be called. Here Two parameters 1 and M are going to be passed.
proc.Start(Application.StartupPath & "\Sambandh.exe", "1 M")