StrataFrame Forum

parameter at the begining ot applicaton

http://forum.strataframe.net/Topic29626.aspx

By Eric Leissler - 2/27/2011

Hi,

I just want to launch my application wiht some parameters

like monappli.exe /param1 /param2

How can i do that ?

thanks

Best regards

Eric
By Eric Leissler - 3/10/2011

hi,Hello, anyone has idea for parameters launches? thanks best regards
By Trent L. Taylor - 3/10/2011

Sure, using parameters is a great idea to add in automated features into an executable.  This is something that I do regularly, but depending on your approach, can be a little work.  I like to create a command line class that can parse the inbound parameters.

To begin, start with the AppMain.vb or program.cs (if you are using an SF project).  Otherwise, just go to your main program entry point.

You can then call the GetCommandLineArgs() if you are running in a WinForms environment.  If you are running in a console app environment, the args will be passed in through the Main entry point as a parameter.

Environment.GetCommandLineArgs()


Next, you can pass these args into a parser that lines up with your desired command line logic.  I will generally write RegEx methods to parse the command line based on what I am expecting coming in and then place that into a collection that has the name and value. 

Hope this helps get you started.
By Eric Leissler - 3/10/2011

Hi Trent

Thanks a lot

Its cool

in the attachement file, (paramstrata.exe)  the video résult.

i put this code in the appmain.vb ( just to understand )


<
STAThread()> _
Public Shared Sub Main()
' -- récupération des paramtres de lancements
Dim toto() As String
toto = Environment.GetCommandLineArgs()
Dim nbparam As Integer
nbparam = toto.Length
If nbparam > 1 Then
For i = 0 To nbparam - 1
MsgBox(toto(i) &
CStr(toto.Length))
Next
End If

 

It running verry well
im going to put a contrib on www.strataframe.fr

Thanks

Best regard

By Trent L. Taylor - 3/10/2011

Glad you got it going!  Thanks for all of your contributions to the forum!!!  Smile