Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Question: Calling an exe file 2

Status
Not open for further replies.
Joined
Jul 13, 2004
Messages
427
Location
US
Hi all,

I would like to call an exe file that i'm using as a resource in my application and pass some command-line arguments to it. I know how to do this if the path to the file is known on the client machine with the Process.Start command, but how do i make this work with an exe that is compiled with the application?

~Intruder~
CEH, CISSP, MCSA/MCSE 2000/2003

 
Do you mean that you do not know where the exe will be or that it will always be wherever the application is?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I guess i would like to include the exe in the application as a resource (if possible..) and call it from there. Is that even possible? If not, what options are there for including it as a resource to copy to the machine, etc, when installing the app? Sorry for the vagueness here - i'm not a programmer, but i'm trying to stumble through some of the basics here.

~Intruder~
CEH, CISSP, MCSA/MCSE 2000/2003

 
Well, the options are pretty limitless when you are talking about just installing it with the app. It just depends on what installation method you use. Let's say for arguments sake that you install the exe in the same dir as your app. Then this code would run it:

using System.Diagnostics;


private static void RunExternalExe()
{
Process proc = new Process();
proc.StartInfo.FileName = "foo.exe";
proc.Start();
}

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
You could write the embedded resource to a folder and launch it from there.

I didn't see a way to create a process from a stream.
 
to be more specific, i want to embed putty (an SSH client) into my home-brew application. This is a simple exe file that i included as a resource in my app... but i'm not sure what to do with it.

Process proc = new Process();
proc.StartInfo.FileName = "putty.exe";
proc.Start();


Doesn't work. changing to the full name (ie: resources.putty) it says i can't convert a byte[] to a string...

Monkey, how would i write this exe to a folder and launch it? What's the best approach here?

~Intruder~
CEH, CISSP, MCSA/MCSE 2000/2003

 
Thank you both for your help!

~Intruder~
CEH, CISSP, MCSA/MCSE 2000/2003

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top