CS-Script 3.20.0

CS-Script settings

Script execution can be controlled/adjusted through the engine runtime settings. These settings can be viewed/edited with a configuration console.  

The configuration console is the utility, which allows to do variety of script engine administrative tasks (installation/uninstallation, enabling shell extensions,  enabling integration with Visual Studio, changing runtime behaviour, accessing the documentation...).

To start the console execute the following command in command prompt:
After the console is displayed you can modify any of the CS-Script settings.

The all settings are divided into three major categories which are represented on the corresponding tabs. In addition to the normal controls (e.g. checkboxes, buttons) you can find LinkLabels which are used to launch external utilities to allow changes of the advanced settings like Advanced Shell Extension. 


This button is used to remove CS-Script from the system.

This button is visible only if the CS-Script file association is broken (e.g. after installation of Visual Studio). You can restore the file association by pressing this button. Note that the file association is not required for CS-Script to work. It rather creates more convenient development environment.

Advanced Shell Extension Tab

This tab displays Advanced shell extensions layout. You can find out more about what this Shell Extension is and how it is different to the explorer Simplified Context Menu in the Advanced Shell Extension chapter.

Use Advanced Shell Extensions
Use this check box to enable or disable Advanced Shell Extension. 

Configure Shell Extension

This LinkLabel is used to launch the Advanced Shell Extension configuration utility. This utility allows you to enable/disable particular Shell Extension menu item, edit menu command and change the menu items order.

By specifying shell command in the text box you can associate script file (.cs) double-click/open event with specific command.  Such command can be as simple as notepad.exe "%1". However any more sophisticated (syntax-aware) text editor would be more appropriate as an editing tool for scripts. The following are examples of the shell commands for using VS Express and Notepad++:
  • "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\VCSExpress.exe" "%1" /Edit  
  • "C:\Program Files\npp.3.3\notepad++.exe" "%1"

You can also select predefined double-click action for script files from the list of predefined actions (e.g. "Run", "Open with..." ).

Visual Studio integration

This LinkLabel is used to launch the Visual Studio Integration configuration utility. This utility allows you to enable/disable or adjust the level of the CS-Script integration with MS Visual Studio IDE(s) installed on your PC.

Simplified Context Menu Tab
In this list of supported simplified explorer Context Menus you can enable/disable particular one depending on you preferences. 


Note: On Windows 8 with Visual Studio 2012 right-click menu configuration may conflict with the CS-Script "Simplified Context Menu" and both Context Menu and Open Action may not work correctly in result. In such cases it is still possible to use CS-Script Advanced Shell Extension as long as it configured for the "Use for all file extensions" (see the Advanced Shell Extension chaprter for details).



Runtime options

Shell command that is executed in order to cleanup any temporary files created by the script engine.  This command is entirely optional. Basically it is a custom action triggered by the script engine when number of consecutive runs (DoCleanupAfterNumberOfRuns) reached. If this command is set the script engine is not required to do any cleanup thus it does the execution in the current AppDomain. This means that the script can be executed faster (however the fastest execution can be achieved only with /c switch).  You can use clearTemp.cs script from the Script Library as a basic cleanup command ("csws.exe clearTemp.cs").  


The number of consecutive runs before CleanupShellCommand would be invoked.

Names of the assemblies (short name) to be referenced automatically by the script being executed. The values must be semicolon separated.  

NOTE: During the script execution with //css_host directive the all DefaultRefAssemblies are ignored. The reason for this limitation is very practical. The default assemblies are not warranted may be valid in the surrogate host environment (e.g. System.Linq.dll fo the host prosess of v2.0 .NET).

Scripts from the Script Library can be executed or imported by the script engine without specifying the full script path. You also can nominate additional folders which will be used by the script engine in the same way. It is just a custom version of the "Script Libraries". All assemblies from SerachDirs are automatically available for runtime for loading (see Using .NET assemblies for details). Multiple search directories should be separated by semicolon (;) the same way as it is done for the environment variable PATH. Another, more convenient way of managing Search directories is to do this with Search Directories utility. you can launch it by clicking the LinkLabel Manage SearchDirs.   


Set this property to the location of the alternative compiler CodeProvider assembly if you want to use non-C# syntax.


Set this property to the location of the Post-Processing assembly if you need to alter/process compiled script juct before the excution.


You can control the type of threading model of the the script being executed by using [STAThread] or [MTAThread] attributes in the script code. If the threading model is not specified in the code it is set to the DefaultApartmentState value of the runtime settings.

This value contains default command line switches. For example if /c ("cached" mode) switch is specified as a default argument, all scripts will be executed with this switch even if the switch is omitted from the command-prompt command.


By using this setting you can  completely (or partially) remove auto-generated files from the script directory. This option (if used) allows you to maintain very clean script directories with script files only. All temporary files (imported scripts, dynamically generated wrappers, script cache) in this case are stored in the specially dedicated temp folder. The possible values for this setting are:

DoNotHide -  Do not hide any auto-generated files.       

HideMostFiles - Hide the most of the auto-generated files (cache and "imported" files).

HideAll - Hide all auto-generated files including the files generated by pre/post scripts.


If this value is set to True all compiler warnings are not displayed. This may simplify navigation in the compiler output.

If this value is set to True the compiled script is loaded for the execution not from the assembly file but rather from it's in-memory copy. This allows avoiding locking the script assembly file during the execution. This may be usefully in some circumstances, for example if you want to delete the compiled script before it's execution is completed. Be careful when using this setting as your script assembly at runtime will have Location property set to empty string (Assembly.GetExecutingAssembly().Location).  Also this value should be set to False for execution of C++ scripts of WWF scripts as CLR expects the assembly to be present in form of file for this type of applications.

If this value is set to True all errors, which the script engine displays to the user, will be reported with the exception stack messages. Otherwise, only the top level exception message is reported. 


Specifies the .NET Framework version that the script is compiled against. This option can have the following values:

v2.0 - .NET Framework 2.0

v3.0 - .NET Framework 3.0

v3.5 - .NET Framework 3.5

v4.0 - .NET Framework 4.0

The default setting is .NET Framework 4.0.
This option is similar to the "Target Framework" option in the General Application Settings of C# Visual Studio 2008/2010 projects.

Note: selecting specific version of CLR as Compiler CLR version does not make your script to be executed under the selected CLR but only compiled. If you want your script to be fully hosted under a specific CLR you need to use the hosating control directive (//css_host) in your script.

Manage SearchDirs

This LinkLabel is used to launch the SearchDirs configuration utility. This utility allows you to add, remove or change the order of the search (probing) directories.


The settings are stored in the css_config.xml file in the CS-Script home directory.

Strictly speaking the location of the css_config.xml file has to be the same as location of the runtime executable. In case of script execution from the command-prompt it is a CS-Script home directory, however for script hosting it is a directory where the host application is.
If you want to restore default settings just delete the css_config.xml file.


Press Update button to check if any update for CS-Script is available.

Updating process is automated, what eliminates necessity for manual downloading and configuration. Always review the settings in the "Runtime options" tab as in result of the "settings migration" they may contain invalid values (etc. absolute paths).

Click corresponding link to access specific documentation resources or send feedback emails.

See Also 

Alternative compilersCommand-line interface | CS-Script version compatibility | Using .NET assemblies