Catch argments by running an .exe

  • Thread starter Thread starter Li Pang
  • Start date Start date
L

Li Pang

Hi,

If anyone who knows how to catch the argments within
a .NET executable file? i.e. run "MyProgram.exe arg1 arg2"
and how to read arg1 and arg2 in VB.NET?

Thanks in advance
 
Hello,

Li Pang said:
If anyone who knows how to catch the argments within
a .NET executable file? i.e. run "MyProgram.exe arg1 arg2"
and how to read arg1 and arg2 in VB.NET?

\\\
Public Sub Main(ByVal astrCmdLineArgs() As String)
Dim i As Integer
For i = 0 To astrCmdLineArgs.Length - 1
Console.WriteLine(astrCmdLineArgs(i))
Next i
End Sub
///

-- or --

\\\
Public Sub Main()
Dim i As Integer
For i = 0 To Environment.GetCommandLineArgs().Length - 1
Console.WriteLine(Environment.GetCommandLineArgs(i))
Next i
End Sub
///
 
Back
Top