By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 1,647 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

exe file geting a parameter from the command lie

P: n/a
i need a exe file that will take a parameter from the command line and
launch the default application that the user has to plays a video file (the
param from command file). and then the exe files finishes.

is that possible. ? how can i do it ? links? articles ?

thanks!
Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
rodrigo guerra <em************@yahoo.com> wrote:
i need a exe file that will take a parameter from the command line and
launch the default application that the user has to plays a video file (the
param from command file). and then the exe files finishes.

is that possible. ? how can i do it ? links? articles ?


Getting parameters from the command line is easy - just make your Main
method take a string array as an argument. For instance:

using System;

class Test
{
static void Main (string[] args)
{
Console.WriteLine ("{0} arguments provided:");
foreach (string arg in args)
{
Console.WriteLine (arg);
}
}
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

P: n/a
Jon Skeet [C# MVP] <sk***@pobox.com> wrote:

Apologies, there was a bug in my code. This line:
Console.WriteLine ("{0} arguments provided:");


should have read:

Console.WriteLine ("{0} arguments provided:", args.Count);

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3

P: n/a
hi jon, thanks for the feedback.

but what about the second part ?
take this parameter (will be a string from a video file "myVideo.mpeg" and
launching in the userīs default player. it would be difficult to do this ?

thanks!

"Jon Skeet [C# MVP]" <sk***@pobox.com> escreveu na mensagem
news:MP************************@msnews.microsoft.c om...
Jon Skeet [C# MVP] <sk***@pobox.com> wrote:

Apologies, there was a bug in my code. This line:
Console.WriteLine ("{0} arguments provided:");


should have read:

Console.WriteLine ("{0} arguments provided:", args.Count);

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #4

P: n/a

"rodrigo guerra" <em************@yahoo.com> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...
i need a exe file that will take a parameter from the command line and
launch the default application that the user has to plays a video file (the param from command file). and then the exe files finishes.

is that possible. ? how can i do it ? links? articles ?

thanks!


Running the default associated program is also easy..

Use the System.Diagnostics.Process class.. Then set the StartInfo to the
name of the file you want to run then it'll start the correct exe for that
file.

Simon.
Nov 15 '05 #5

P: n/a
rodrigo guerra <em************@yahoo.com> wrote:
but what about the second part ?
take this parameter (will be a string from a video file "myVideo.mpeg" and
launching in the userīs default player. it would be difficult to do this ?


Look at System.Diagnostics.Process. I can't remember offhand whether
you need to explicitly use something to do the equivalent of "start"
under the command prompt, or whether you can just give the filename -
either way, it may well not work on 98.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #6

P: n/a
thanks for the System.Diagnostics.Process class tip, iīm gonna look for it.

[]īs rodrigo.

"Simon Johnson" <ck***@hotmail.com> escreveu na mensagem
news:br**********@titan.btinternet.com...

"rodrigo guerra" <em************@yahoo.com> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...
i need a exe file that will take a parameter from the command line and
launch the default application that the user has to plays a video file

(the
param from command file). and then the exe files finishes.

is that possible. ? how can i do it ? links? articles ?

thanks!


Running the default associated program is also easy..

Use the System.Diagnostics.Process class.. Then set the StartInfo to the
name of the file you want to run then it'll start the correct exe for that
file.

Simon.

Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.