Tuesday, December 30, 2008

Script Code: Comparing Kix and VBScript (part 2)

In the previous blog post, I illustrated how KixTart provides time-saving macro variables for many common items that VBScript (or Windows Scripting Host) does not.  Specifically @userid, @wksta, and @domain.  The net result being that you often need to add more code to provide the same functionality.  The same is also true in reverse.  This is yet another example of my statement that script languages are tools, and some tools are better at certain tasks than others.  In this example I will show some time-saving features in VBScript that require additional code in KixTart to provide identical capabilities.

Case 1 - Adding and Subtracting Date Values

VBScript provides the DateAdd(), DateDiff() functions to do things like determine the date which would be "x" days from another date, or determine how many seconds, minutes, hours, days, weeks, months or years are between two specified dates.  To do this with KixTart you would need to add some custom code (or download a handy UDF sample) which defines a function you can call to accomplish the same result.

Case 2 - Formatting Date Values

VBScript provides the FormatDateTime() function, along with defined constants such as vbShortDate, and vbLongDate (among others) to take a date string and produce a different formatted date string.  The built-in Now() function returns the current Date and Time in the format of "12/30/2008 8:23:52 PM".  For example...

    FormatDateTime(Now, vbShortDate)

Would display something like "12/30/2008"

For a discussion about formatting date values with KixTart, check out the KixTart Forums.


There are many advantages to KixTart over VBScript however.  Some examples would be:
  • Native "Include" capability for merging scripts
  • Built-in time-saving macro variables
  • Native string expansion and evaluation
  • Provides native features similar to FileSystemObject, ADSI, WMI, and features for enumerating and managing printer connections, drive mappings and so forth.
  • KixTart is extremely portable and can be invoked using a remote instance of Kix32.exe in many situations (no need to install software on the computer where a script is executed)
  • Both KixTart and VBScript benefit from ginormous amounts of free sample scripts on the Internet and vast numbers of free support groups, discussion forums and so on.
So, basically, they are very comparable, however, you will find a large number of people that swear by one or the other as being more capable.  I really don't care.  They both work great.
Post a Comment