views:

1053

answers:

14

I want a small (< 30MB) standalone Windows executable (a single file) that creates a window which asks the user for the location of a directory and then launches a different program in that directory.

This executable has to run on XP, Vista, Server 2003, and Server 2008 versions of Windows in 32-bits and 64 bits on x86-64 architecture as well as Itanium chips.

It would be spectacular if we only had to build it once in order to run it on all these platforms, but that is not a requirement. This is for a proprietary system, so GPL code is off-limits.

What is the fastest way to put this together?

These are some things I'm looking into, so if you have info about their viability, I'm all about it:

  • Perl/Tk using perl2exe to get the binary.
  • Ruby with wxruby
  • Learn MFC programming and do it the right way like everybody else.
+2  A: 

You could do this in MFC and have an executable in under 100k. In general, if you want to keep the size of your executables down, you can use UPX to perform exe compression. If you want an example, take a look at uTorrent. It's a full featured BitTorrent app in less than 300k of executable.

Douglas Mayle
You meant a full featured BitTorrent app, no?
Vinko Vrsalovic
+11  A: 

What about a WSH script? It won't be an exe, right, but to ask for a folder I don't see the need for an exe file, much less a 30Mb one...

A 1Kb script, save it as whatever name you like with vbs extension and run it. This, in case it's not clear, asks you for a folder name and then runs calc.exe from the system32 subdirectory. You can of course do a lot better than this in 2 or 4 Kb.

Set WshShell = WScript.CreateObject("WScript.Shell")
win = InputBox("Please type your Windows folder location.")
If Right(win,1) <> "\" Then
  win = win & "\"
End If
WshShell.Run win & "system32\calc.exe"

To add a Folder Browser dialog instead of an InputBox, check this out.

Clear benefits are:

  • Simplicity (well, VB is ugly, but you can use JScript if you prefer), no need to compile it!
  • Compatibility, works on every windows machine I have available (from 98 onwards)
Vinko Vrsalovic
+6  A: 

Quickest way on Windows for a lightweight and fast GUI? One word.. Delphi! It lacks the 64 bit support for now but then FreePascal would come to the rescue.

utku_karatas
I keep finding myself answering these kinds of questions with Delphi, even though I've never used it.
MusiGenesis
Codegear have a 64-bit compiler on the roadmap...
Roddy
Free Pascal has a Delphi like RAD too, Lazarus. See http://lazarus.freepascal.org
Marco van de Voort
A: 

wxWidgets; it's cross platform, free, open source and easy to learn

Jaywalker
+3  A: 

For all of its flaws, Visual Basic has historically been great for super-simple apps like this.

Matt Dillard
If you've got a copy of visual studio, it's hard to beat VB for this kind of GUI programming.
Electrons_Ahoy
But the apps are all dependent on the VB runtimes or .NET.
MusiGenesis
@MusiGenesis: very true. Also - costs money for those cases where that matters.
Electrons_Ahoy
+2  A: 

Python with either xwWidgets or Tkinter should be able to do this with almost no effort at all. Runs on everything, and py2exe will get you a standalone executable.

Electrons_Ahoy
Visual Studio Forms Editor is an order of magnitude faster to write, and gives you a better result, unless I am overlooking some killer-app python forms editor.
Dustin Getz
I'm not sure about wxWidgets -- I'm a tk guy, but for those with experience writing GUIs in dynamic languages like python or tcl, simple applications like this take only minutes to create. I think you'd be hard pressed to be an order of magnitude faster.
Bryan Oakley
There are some pretty killer python form editors out there, but a basic "form with a couple of buttons" app should only take 10 minutes or so to knock out with either tkinter or tk, and thats mostly spent pasting in the tkinter demo code. :)
Electrons_Ahoy
+5  A: 

I'd use .NET and WinForms. The idea of scripted solution is appealing, but in practice I often find you end up jumping through hoops to do anything beyond the basic case and still don't have the flexibility to do everything you want.

The scripting solution takes so little to develop and maintain that it's nearly zero damage to throw it away and rewrite it in a 'real' platform, _if_ the need arises; especially when 'doing it right' would involve builds for many architectures and so on.
Vinko Vrsalovic
i don't think .NET works in XP out of the box
Javier
i dunno about XP0, but XPsp2 definitely has it
Dustin Getz
XP comes with .NET 1.1. Not the commonly used 2.x to my best knowledge
Marco van de Voort
+5  A: 

Having a small stand-alone application and developing it quickly are, I'm sorry to say, usually conflicting requirements.

To be honest, given how incredibly simple the application is, I would write it in C with direct Win32 calls: one call to SHBrowseForFolder() to get the directory, and one to ShellExecuteEx() to run the program. Even MFC is far too heavy-weight for such a modest application. Set the C runtime to be statically linked and you should be able to keep the size of the stand-alone executable to less than 100k. A decent Windows C coder should be able to knock that up in less than an hour, assuming you have one to hand.

DavidK
you've apparently never used a scripting language with a decent toolkit.
Bryan Oakley
Does never having used a scripting language somehow negate being able to write the program in Win32? The benefits of having it being a pure Win32 app means it runs anywhere without having to install the scripting tool.
Joel Lucsy
No but I think the point is, the "under an hour" is much longer than it would take in a scripting env like Powershell. It should take about 7 minutes in VB.NET, and that includes Visual Studio startup time.
Cheeso
A: 

Similar to what Vinko Vrsalovic said, you can use a HTA application. It is as easy as building a webpage with windows scripting host functionality. I have built a few utilities with jscript and it is really easy and quick http://msdn.microsoft.com/en-us/library/ms536496(VS.85).aspx

artificialidiot
A: 

These responses are unbelievable.

Visual Studio Forms editor lets you draw out WinForms and autogenerates the boilerplate GUI code (which is a pain in the ass at best for most other languages and toolkits). Then you can use C# or any other .NET language. .NET has stock widgets for file pickers. I could write that script in 20 minutes and it will run on every one of your target platforms for free. Draw out the GUI, drag-n-drop a file picker, fill out maybe two hooks to do the "launch a different file than they wanted" thing, done.

Dustin Getz
Windows Vista comes with a version of the .NET Framework pre-installed. In earlier versions of Windows, the .NET Framework had to be installed separately, either through Windows Update or as part of another program’s installation.
Vinko Vrsalovic
The question says "standalone", which is kind of vague but usually means a native EXE.
MusiGenesis
XP sp2 ships with .net
Dustin Getz
+1  A: 

For my money Tcl/Tk is absolutely the quickest path. You can have a single file executable (including custom images, dlls, etc) using something called a "starpack" -- a virtual filesystem that is both tcl interpreter and application code. I think it would weigh in at maybe a couple megabytes.

From your specifications it would take me personally maybe 15 minutes to get a first working version.

Oh, and Tcl/Tk has a BSD license so it's more free than your typical free software :-)

Bryan Oakley
+1  A: 

I agree with the Tcl/Tk answer above. For more information about the starpack that he refers to, see: http://www.equi4.com/tclkit/ it's a Tcl/Tk interpreter available for various OS's all in about 1MB. In the past there apparently has been concerned about the look and feel of Tcl/Tk UI's, but this has been addressed by a new framework named "Tile" that supports the native look and feel of the user's OS.

George Jempty
+1  A: 

I use HTA (HTML Application) for quick-and-dirty form & script applications. See Microsoft's HTA Developers Center for details and examples. This basically uses HTML for the form, and any HTML-accessible scripting language for the script. Normal browser security is bypassed so that you can get at almost all OS internals. The above site also contains links to several tools that nearly automate the scripting part for you.

Ken Paul
+1  A: 

For a quick and dirty GUI program like you said, you can use an AutoIt script. You can even compile to an exe.

For an GUI example of AutoIt, you can check my stdout redirect script in a previous answer here

PabloG