how can i launch a specific .net form from outside of the exe? using a batch file

I have a .net application, i would like for any specific form to be launched using a batch file...

now i know if i...

click on the solution properties and then click the debug tab select the start action under start options, i can specify command line arguments.

What do I need to type in the command line arguments to launch any specific form?

I tried this in the batch file, but it doesn't work:

c:\TestFolder\TestApp\test.exe /a

c:\TestFolder\TestApp\test.exe /b

c:\TestFolder\TestApp\test.exe /c

how can i get my application to recognise these commands and launch the right form? or what other way can i do it?

Answers


I have figured it out...

First under the command line arguments I added the commands, within the solution properties.

Then in Application.Designer.vb (Program.cs Main() if you're using c#) Under

Protected Overrides Sub OnCreateMainForm()

I added the following...

    <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
    Protected Overrides Sub OnCreateMainForm()
        Try

            If Me.CommandLineArgs(0) = "/a" Then
                test.openForm1()
            ElseIf Me.CommandLineArgs(0) = "/b" Then
                test.openForm2()
            ElseIf Me.CommandLineArgs(0) = "/c" Then
                test.openForm3()
            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

test is the name of the exe i'm compiling.

this in the batch file, this works...

c:\TestFolder\TestApp\test.exe /a

c:\TestFolder\TestApp\test.exe /b

c:\TestFolder\TestApp\test.exe /c

PLEASE NOTE:

You MUST remember to specify AT LEAST ONE command line argument in your project properties, it can be any value, just not empty.

Click on DEBUG in the project properties > go to the Start Options > Command Line Arguments: "/anything"

If you miss this out, you may get a System.Argument.OutOfRangeException / Index was out of range.


Need Your Help

Bash command substitution executing before earlier code

bash shell unix terminal

ssh -i "path/to/my/key.key" ip.ip.ip.ip "mkdir a/a; sql 'query;' &gt; a/a/file.txt; if [ -f a/a/file.txt ]; then if [ $(wc -l a/a/file.txt) -ge 2 ]; then echo 'done'; fi; fi; exit"

The best way to understand Hibernate internals

java hibernate design-patterns architecture internals

I'm trying to understand how Hibernate works under the hood, how it manages lazy loading, transactions, data mappers, unit of work, identity maps, etc.