I've seen a few topics on the discussion boards about people wanting console-less .exe's to run with Fantom. So this is directed at the newbies like myself who want a semi solution.
After a couple of weeks of developing, I grew tired of having consoles piling up from opening multiple Flux windows, so I got sidetracked into finding a way to get rid of that pesky console and ran into this snippet of C# code: http://www.jonasjohn.de/snippets/csharp/run-console-app-without-dos-box.htm
I downloaded visual C# 2010 Express (which is free), started a new project as ConsoleApplication, changed the project properties Output type to Windows Application, modified the code to this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace fanw
{
class Program
{
static void Main(string[] args)
{
// Application path and command line arguments
string ApplicationPath = "C:/FAN_HOME/bin/flux.exe"; //this is important
string ApplicationArguments = ""; //this is important
// Create a new process object
Process ProcessObj = new Process();
// StartInfo contains the startup information of
// the new process
ProcessObj.StartInfo.FileName = ApplicationPath;
ProcessObj.StartInfo.Arguments = ApplicationArguments;
// These two optional flags ensure that no DOS window
// appears
ProcessObj.StartInfo.UseShellExecute = false;
ProcessObj.StartInfo.CreateNoWindow = true;
// If this option is set the DOS window appears again :-/
// ProcessObj.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
// This ensures that you get the output from the DOS application
ProcessObj.StartInfo.RedirectStandardOutput = true;
// Start the process
ProcessObj.Start();
// Wait that the process exits
ProcessObj.WaitForExit();
// Now read the output of the DOS application
string Result = ProcessObj.StandardOutput.ReadToEnd();
}
}
}
built the project, found where the .exe file was being generated, sent it to my desktop and voila I have console-less flux! :)
This got me thinking, could I use this same code to generate an executable that would run my fantom projects without the window?? Indeed!
By changing these two fields,
string ApplicationPath = "C:/FAN_HOME/bin/fan.exe"; //directory to your fan compiler
string ApplicationArguments = "hello"; //name of your pod/pods go here
I managed to run my own fantom applications without a console window!
I don't think this is a final solution to this issue (which I think is a Windows OS problem more then a fantom problem) but I think its a step in the right direction. If anyone out there with some C# experience could take this and make a standalone Fantome .exe generator or a similar solution for the .net platform, that would be awesome. (This is my first time touching C# ever)
Hope this helps!
andyMon 1 Aug 2011
Looks cool yliu!
brianTue 2 Aug 2011
At some point, I will fix the C launcher code to do this too (without having .NET dependency). I also am planning Windows code for running Fantom programs as services. It is amazing how insanely difficult it is to the simplest things like running a program in Windows.
yliu Mon 1 Aug 2011
I've seen a few topics on the discussion boards about people wanting console-less .exe's to run with Fantom. So this is directed at the newbies like myself who want a semi solution.
After a couple of weeks of developing, I grew tired of having consoles piling up from opening multiple Flux windows, so I got sidetracked into finding a way to get rid of that pesky console and ran into this snippet of C# code: http://www.jonasjohn.de/snippets/csharp/run-console-app-without-dos-box.htm
I downloaded visual C# 2010 Express (which is free), started a new project as ConsoleApplication, changed the project properties Output type to Windows Application, modified the code to this:
built the project, found where the .exe file was being generated, sent it to my desktop and voila I have console-less flux! :)
This got me thinking, could I use this same code to generate an executable that would run my fantom projects without the window?? Indeed!
By changing these two fields,
I managed to run my own fantom applications without a console window!
I don't think this is a final solution to this issue (which I think is a Windows OS problem more then a fantom problem) but I think its a step in the right direction. If anyone out there with some C# experience could take this and make a standalone Fantome .exe generator or a similar solution for the .net platform, that would be awesome. (This is my first time touching C# ever)
Hope this helps!
andy Mon 1 Aug 2011
Looks cool yliu!
brian Tue 2 Aug 2011
At some point, I will fix the C launcher code to do this too (without having .NET dependency). I also am planning Windows code for running Fantom programs as services. It is amazing how insanely difficult it is to the simplest things like running a program in Windows.