Launch .CSX as conveniently as .BAT files

first, get Chocolatety if you don’t already have… killer handy

then make sure you have a .csx runner… either ScriptCS or csi.exe starting with Visual Studio 2015 update 3

setup the .csx to runner file association

%~2 means all args starting with #2… see ftype docs for more

FYI for TCC LE folks, apparently i’ve stumbled into a rare backwards compatibility gap… TCC LE doesn’t seem to support the %~2 syntax like cmd.exe and it escapes “%” differently, so substitute that portion of the ftype line above with “%%1 — %%2 %%3 %%4”

lastly, edit your PATHEXT system environment variable to include .CSX which allows us to leave off the extension to launch our scripts just like native commands! =)

TCC LE requires OPTION > Startup > PathExt for the above to work

refreshenv comes from Chocolately… it refreshes the current command line environment from registry, which we just updated via setx

or runas admin > C:\Windows\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables

with all that fun stuff in place, we can finally do something nifty like this:

beautiful! =)

see my other CSX examples