
Really dumb question: How do I call one .EXE from another, passing parms into the constructor?
The only dumb question is the one that is unasked.
C# makes a lot of this
type of stuff easier, although VB.NET is more flexible. Let's assume a non
GUI (or Console) app for starters.
NOTE: This assumes you are using the RTM, as this will not work with some
betas:
Module Module1
Sub Main(ByVal strArgs() As String)
Dim intCounter As Integer
For intCounter = 0 To UBound(strArgs)
Console.WriteLine(intCounter & ". " & strArgs(intCounter))
Next
Console.Read()
End Sub
End Module
Now, you can call this app (I called it Test App), like this:
testApp.exe I can now accept parameters on start.
The Main() here is the starting point of the app, and can accept parameters.
The other way (not preferred):
-------------------------------
Add a reference to the Microsoft.Visual.Basic DLL and use the namespace. You
can then access the Command object (for command line arguments) and parse it
out. The parsing will add additional overhead, but it will feel familiar.
Here is the code:
Module Module1
Sub Main()
'NOTE: Split(x," ") and Split(x) are the same.
Dim strArgs() As String = Split(Microsoft.VisualBasic.Command)
Dim intCounter As Integer
For intCounter = 0 To UBound(strArgs)
Console.WriteLine(intCounter & ". " & strArgs(intCounter))
Next
Console.Read()
End Sub
End Module
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge
****************************************************************************
****
Think outside the box!
****************************************************************************
****
Quote:
> Newbie question: I wrote and compile 2 .EXEs which display windows forms.
> From the VB.NET program I'm trying to call another EXE and pass parameters
> to its constructor. I'm trying to get this to work using AppDomain and
> CreateInstance. And it works ok w/o parameters. But I can't get the
syntax
> right to pass parms. How do I do this? Is there an easier way, besides
> AppDomain and CreateInstance?
> Thank you in advance.