Scripting with C# Script

18 Feb

I have been playing cscript recently and I have found it a better alternative to Jscript. With C# Script you have the power of C# Language with the scripting capability. Hence, you don’t have to compile your code when making modification to it.

You also have the option to create an executable out of the script.

Here is an example of accessing COM from C# Script. Notice the include tag on the first line

//css_prescript com(SYSINFO.SysInfo.1, SisInfoLib);
using System;
using SisInfoLib;
class Script
static public void Main(string[] args)
SysInfoClass sysInfo = new SysInfoClass();
switch (sysInfo.ACStatus)
case 0:
Console.WriteLine(“Not using AC power”);
case 1:
Console.WriteLine(“Using AC power”);
Console.WriteLine(“Unknown AC power status”);
if (sysInfo.BatteryLifePercent != 255)
Console.WriteLine(“Battery life ” + sysInfo.BatteryLifePercent + “%”);
Console.WriteLine(“Battery charge status not known”);

Leave a comment

Posted by on February 18, 2008 in Development, Technology, Test Automation, Testing


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: