Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to run an exe with parameters
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
00975340
Message ID:
00975416
Vues:
12
Hi Einar,
Thanks for your reply.

Am I right then , say if you wanted to pass 3 paraneters you would call the program like:
MyProg.exe "Param1","Param2",100
(Asuming first two are Charcater parameters and third is Numeric

And in main calling mehod it would be something like:
(Pardon the incorrect syntax)

static void Main(string[] args)
if args[0] = "abc" { do something}
if args[2] = "def" {do smoethingB}
if args[3] = 100 {do something}


Just as I am writing this I notice i have a mix of types in the parameters !!is this going to cause a problem having 2 character parameters and 1 numeric .... can you have this in C# as you can in VFP ?


Regards,
Gerard


>Gerard,
>Just to post an example to what Kevin said in his reply. This is some code from a screensaver I wrote that accepts parameters:
>
>		static void Main(string[] args)
>		{
>			try
>			{
>				if (args.Length > 0)
>				{
>					if (args[0].ToLower().Trim().Substring(0,2) == "/c")
>					{
>						// Code for settings and such
>						MessageBox.Show("This screen saver has no options that you can set.","MyScreenSaver",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
>					}
>					else if (args[0].ToLower().Trim().Substring(0,2) == "/s")
>					{
>						Application.Run(new frmMain());
>					}
>				}
>				else
>				{
>					Application.Run(new frmMain());
>				}
>			}
>			catch
>			{
>				// nothing to catch
>			}
>		}
>
>
>Hope this helps.
>
>Einar
>>Hi.
>>I want to create an exe in dot net (C Sharp) wjich would be run as follows:
>>
>>MyProg.exe Param1,Param2,Param3
>>
>>In other words, I want to take in a few parameters to the Exe.
>>(In VFP I would do this by having a MyProg.prg was my main Prg and have 3 parameters in it )
>>
>>Regards,
>>
>>Gerard
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform