Launch a .csx (scriptcs) C# script directly without opening a command line window

You can make your own version of csi.exe that runs without a console.

Simply create a new project, make sure the Type is set to WinForms instead of Console, then add the C# Scripting package from NuGet and copy-paste the csi.exe source code.


A workaround is to create your own program that launches it in the background for you, like csws.exe would.

Start by creating a console app.

public static void Main(string[] args)
{
    var startInfo = new ProcessStartInfo("path to csi.exe")
    {
        CreateNoWindow = true,
        Arguments = args[1],
        RedirectStandardOutput = true,
        UseShellExecute = false,
    };
    Process.Start(startInfo);
}

(You'll obviously want to pass the rest of the arguments and check to make sure a file was passed etc, but this should get you started. And I wrote this answer on my Mac as my Windows box is in the shop, so I can't guarantee it'll work.)

Then have the console app not show a window by changing it to a Windows application from a Console application on the project properties screen as described in this question.

Lastly, configure .csx files to always open with your application. Then you can double click them and they'll run with no window.