Is there ready made solution to run program (let's call that launcher.exe) with .exe file extension (extension is important) that looks for static configuration file, for example launcher.cfg, and launches another program specified within configuration file.

Or maybe launcher.exe that will execute launcher.cmd or some other script that can be used to pass control forward.

Another explanation of requirements if that is not already clear enough:

1. User or some other program launches program.exe
2. program.exe launches program.cmd which is shell script executed by cmd.exe

Important thing is that launcher.exe is program with .exe file extension and it does not need any command line arguments to launch another script or program with command line arguments.

  • May I ask why? This is a fairly trivial task in most major programming languages, but I don't see the purpose. You want to run a executable with extension .exe that launches a .bat? – Bob May 11 '12 at 10:22
  • @Bob Yes, that behavior is needed when replacing parts of application that consists of many .exe files that are launcher by application's controller module. – Sampo Sarrala - codidact.org May 11 '12 at 10:25

I'm not aware of any ready made program that does this.

I had a bit of spare time, so here's a quick C++ program.

#include <cstdlib>
#include <cstdio>
#include <cstring>

#define COMMAND_PRE "call "
#define COMMAND_POST ".bat"

using namespace std;

int main(int argc, char *argv[]) {
    char command[strlen(COMMAND_PRE) + strlen(argv[0]) + strlen(COMMAND_POST) + 1];

    strcpy(command, COMMAND_PRE);
    strcat(command, argv[0]);
    strcat(command, COMMAND_POST);

    printf("Running \"%s\"", command);


Of course, Norton was nice enough to call it high risk because of the system(command); line, which just executes a .bat file. Whatever, I can't be bothered trying to find an antivirus-safe method (and Norton's "SONAR" protection overreacts quite often).

Name the program whatever.exe and it'll run the file whatever.exe.bat. In other words, it'll take its own filename (and path), append .bat to the end, and run it.

You can compile it yourself from the above source. I'll also provide a download link to the compiled program here, but use at your own risk - no one here is responsible for what may happen

| improve this answer | |
  • +1 This answer is good enough and i've already thought that i may need to make one for that purpose. I was just lazy in setting up dev env to virtualbox which is my only winmachine and thought if someone already knows some solution for that... actually application that uses many .exe files is windows :) – Sampo Sarrala - codidact.org May 11 '12 at 11:20

I have found alternate solution for this which I think is not as good as Bob's answer.

However, it is working solution and I'll post it for future reference:

.cmd and .bat files can be compiled to .exe files (with some limitations) with batch compiler found at sf.net/projects/batchcompiler.

This way one can write batch file

start anotherbatch.cmd /arg1 /arg2

And compile that to batchfile.exe

| improve this answer | |
  • Assuming the limitations you mentioned don't include this, you can mimic my program: echo Running "%0.bat" followed by call %0.bat followed by pause should do exactly the same thing. – Bob May 11 '12 at 11:57
  • @Bob This is one of limitations i mentioned, at least with compiler i linked, it will not expand %0 at runtime but save it as constant value while compiling so compiled program will not behave exactly as original batch file. – Sampo Sarrala - codidact.org May 11 '12 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.