Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Is there a way in Windows to launch a .csx script directly (e.g. by double clicking the file, or from the start menu, or via an app launcher like Launchy) such that the script runs in the background without opening a command line window?

For example, say I have a simple "lowercase.csx" script which simply takes whatever text is in my clipboard, converts it to lowercase, and puts the result back in my clipboard. I want to be able to double click on that .csx file and have that run completely in the background without opening any kind of window.

Currently both ScriptCS.exe and the new csi.exe launcher that comes with VS2015 Update 1 will open a console window when running a .csx file, even if that file doesn't output anything to the console.

Note: I know that a new window isn't opened if you launch a script from a console window. What I want to to launch a script in a non-command line context and have it open no windows.

Note2: The equivalent of what I want in "CS-Script" (a ScriptCS alternative) is to launch the files using "csws.exe".

like image 803
ivanatpr Avatar asked Dec 01 '15 02:12

ivanatpr


2 Answers

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.

like image 172
SLaks Avatar answered Oct 20 '22 15:10

SLaks


scriptcs does not support this. However there is an application that solves this problem: https://gitlab.com/Lions-Open-Source/ScriptCSW

like image 36
Alex Avatar answered Oct 20 '22 15:10

Alex