0

Is it possible to include a command line utility in my C# WinForm Application? To be more specific, is it possible to compile a command line util into an .exe file so that I can write a GUI to control the command line tool?

Helgi
  • 5,428
  • 1
  • 31
  • 48
Norynda
  • 51
  • 5
  • You can control it by starting the command line tool with parameters. – Oskar Kjellin May 14 '12 at 20:08
  • yeah I know that, but I want to have in compiled into my .exe file and not having it roaming around in the install directory. – Norynda May 14 '12 at 20:13
  • You could have it as a resource that you then unpack when you start the app – Oskar Kjellin May 14 '12 at 20:14
  • That will be difficult, you'll have to find a temporary location to unpack the resource. You can't just dump it in the same folder as your app because the user is unlikely to have write permission to that folder. – Cody Gray - on strike May 14 '12 at 20:15
  • So you mean that i unpack it to an actual file and then run it as command line tool and after all is done clean it up again? – Norynda May 14 '12 at 20:16
  • @CodyGray Finding a temporary directory is not very hard? – Oskar Kjellin May 14 '12 at 20:16
  • possible duplicate of [How do I create a C# app that decides itself whether to show as a console or windowed app?](http://stackoverflow.com/questions/807998/how-do-i-create-a-c-sharp-app-that-decides-itself-whether-to-show-as-a-console-o) – Erik Philips May 14 '12 at 20:18
  • @Erik Philips, not really I want to write a GUI for an console only appliction. To give you even more detail, I have an command line tool to tag m4v files and I want to control this tool via an GUI – Norynda May 14 '12 at 20:22
  • 3
    Anyway, I'm not sure what the motivation is to have a single EXE. If you're writing something targeting the .NET Framework, you're not going to be able to avoid a sea of dependencies. You'll essentially require an installer (or some other deployment mechanism like ClickOnce), therefore what does it matter if there's another EXE you depend on? – Cody Gray - on strike May 14 '12 at 20:22

1 Answers1

2

If you have a dependency on another application, then packaging that utility inside your EXE is a bad idea, because that means every time that dependency is updated, you should be updating your application. I would just build your windows application and help the user find the required EXE. This is how Exact Audio Copy works which relies on another 3rd party application for encoding (specifically LAME).

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
  • Decreasing coupling seems like a good idea in theory, but probably won't bear out all that well in practice. If the command line utility that he's interfacing with undergoes non-trivial changes, then the GUI interface will need to change in response. – Cody Gray - on strike May 14 '12 at 20:43
  • Actually it does, for multiple application I use. When LAME gets an update that doesn't require me to get a new GUI for EAC, I can replace the console lame.exe without fear. By tightly coupling the two, it simply increases complexity and reduces options. – Erik Philips May 14 '12 at 20:53