views:

155

answers:

4

The easiest way to think of my question is to think of a single, simple unix command (albeit, this is for windows) and I need progmatic access to run it.

I have a single command-line based executable that performs some unit of work. I want to call that executable with the .net process library, as I can do with any other executable.

However, it dawned on me that there is potential for the dll to become useless or break with unintended updates to the executable or a non-existant executable.

Is it possible to run the executable from the Process object in the .net framework, as I would an external executable file?

A: 

Is this where PInvoke can help?

IainMH
If I'm not mistaken, Pinvoke is for running code within other dlls, I'm looking to embed an exe in the same dll (or even exe) as the currently running code.
casademora
+1  A: 

No, you can't execute it directly. You could probably unpack it to a temporary directory and execute it from there.

garretmagin
A: 

Depending on the functionality of the command line program you want to run, it might be possible to duplicate the functionality in PowerShell, where you can embed the PowerShell runtime in your .NET application.

Steven Murawski
+1  A: 

I found an article that has some sample code to what @garretmagin says:

http://www.cs.nyu.edu/~vs667/articles/embed_executable_tutorial/

casademora