From: Breakable on
Hi, I am having a lot of pain with a simple issue:
Trying to execute a command with parameters
something like "iexplore http://google.com". I am not sure what the
command will be or how the command will be formatted, so I would love
not to have to parse it (cover all situations), however
Process.Start
gives me "The system cannot find the file specified" error when i try
to
Process.Start("iexplore http://google.com");
which I am not able to overcome.
Of course this works:
Process.Start("iexplore","http://google.com");
but now I need to parse, which I would like to avoid.
The only workaround I see is creating a batch file, which I would love
to avoid.
Is there any way to execute a command line from .net without parsing
it first?
From: Jackie on
On 5/19/2010 19:15, Breakable wrote:
> Hi, I am having a lot of pain with a simple issue:
> Trying to execute a command with parameters
> something like "iexplore http://google.com". I am not sure what the
> command will be or how the command will be formatted, so I would love
> not to have to parse it (cover all situations), however
> Process.Start
> gives me "The system cannot find the file specified" error when i try
> to
> Process.Start("iexplore http://google.com");
> which I am not able to overcome.
> Of course this works:
> Process.Start("iexplore","http://google.com");
> but now I need to parse, which I would like to avoid.
> The only workaround I see is creating a batch file, which I would love
> to avoid.
> Is there any way to execute a command line from .net without parsing
> it first?

This should open in the default browser...

ProcessStartInfo startInfo = new ProcessStartInfo("http://www.google.com");
startInfo.UseShellExecute = true;
Process.Start(startInfo);
From: Jackie on
On 5/19/2010 19:15, Breakable wrote:
> Hi, I am having a lot of pain with a simple issue:
> Trying to execute a command with parameters
> something like "iexplore http://google.com". I am not sure what the
> command will be or how the command will be formatted, so I would love
> not to have to parse it (cover all situations), however
> Process.Start
> gives me "The system cannot find the file specified" error when i try
> to
> Process.Start("iexplore http://google.com");
> which I am not able to overcome.
> Of course this works:
> Process.Start("iexplore","http://google.com");
> but now I need to parse, which I would like to avoid.
> The only workaround I see is creating a batch file, which I would love
> to avoid.
> Is there any way to execute a command line from .net without parsing
> it first?

Your code should probably work if you add the directory to iexplore.exe
into the PATH environment variable, because the system does not
automatically know exactly where iexplore.exe is located.
I believe you want to do what I suggested in my previous post, however.
From: Patrice on
How are defined the command and its parameters ?

Assuming you want to let the user define what to start you can take the
"External Tool" feature of VS as an example. It provides the user with :
- a textbox that allows to enter the command (including a browsing button
that allows to select the file including the path)
- a text box that allows to enter the arguments

Parsing is not general (ie "a b c" could be launching "a b" with argument
"c" or launching "a" with "b c", you can assume the later but strictly
speaking there is no way to choose between both).
Also if the user doesn't provide the path to the EXE file, then you would
have to find it (or even worse you could use another EXE file that the one
intended just because it is in the search path or the same command could
change later if the search path is altered etc...).

The UI described above and that is used in VS, solves those problems (by
letting the user to enter the command including the full path and its
arguments separately).

--
Patrice

"Breakable" <igalvelis(a)gmail.com> a �crit dans le message de groupe de
discussion :
ba2702d8-da35-4425-8e01-24318e26db50(a)c11g2000vbe.googlegroups.com...
> Hi, I am having a lot of pain with a simple issue:
> Trying to execute a command with parameters
> something like "iexplore http://google.com". I am not sure what the
> command will be or how the command will be formatted, so I would love
> not to have to parse it (cover all situations), however
> Process.Start
> gives me "The system cannot find the file specified" error when i try
> to
> Process.Start("iexplore http://google.com");
> which I am not able to overcome.
> Of course this works:
> Process.Start("iexplore","http://google.com");
> but now I need to parse, which I would like to avoid.
> The only workaround I see is creating a batch file, which I would love
> to avoid.
> Is there any way to execute a command line from .net without parsing
> it first?
>

From: Jackie on
On 5/19/2010 19:31, Jackie wrote:
> Your code should probably work if you add the directory to iexplore.exe
> into the PATH environment variable, because the system does not
> automatically know exactly where iexplore.exe is located.
> I believe you want to do what I suggested in my previous post, however.

Maybe I didn't really need to give you any examples, probably because
the iexplorer was not found anywhere in the current directory,
system/windows directory, in any path in the PATH environment variable
or anywhere else it tries to look.