A command line argument seems the cleanest solution, you can use
GetCommandLine[
^] from your exe file.
e.g.
Starting the program like
myprog.exe
will show a messagebox, but
myprog.exe -console
will use console output.
When opening myprog.exe via the explorer, no command line arguments are added so you'll get a messagebox if you start it manually.