Wednesday, April 22, 2009

VBScript vs KiXtart - Round 20

Another comparison of VBScript and KiXtart to show how different scripting tools can be. In this case, here's a chunk of code from a login script that reads a user's "full name" from Active Directory, and sets a local User variable to that value. This is often necessary for legacy applications that look for environment values with specific names because they suffer from either (A) lack of customer budget to buy the newer product version which knows how to query Active Directory, or (B) lack of vendor intelligence in producing a hotfix or upgrade to address the shortcoming. In either case, here's how it might work with VBScript:


Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
strFullName = objUser.givenName & " " & objUser.sn
Set objShell = CreateObject( "WScript.Shell" )
objShell.Environment("User").Item("FullName") = strFullName


Not bad. It works. But if you do this same chore using KiXtart 4.6x, it would look like this:


$strFullName = @fullname
SET "FullName=$strFullName"


Hmm. This example is obviously not all-inclusive of comparison between the strengths of each language, but it is just one illustration of how different they can be.

No comments: