.Net Classes within VBScript: Doing Randomness and Arrays the Easy Way
·2 mins
Back in 2007, the Microsoft Scripting Guys posted a article titled “Hey, Scripting Guy! Be Careful What You Say.” This article changed everything in the way I scripted because it should how simply you can access some .Net classes through COM callable wrappers. The two they focus on are “System.Random” and “System.Collections.ArrayList”.
Set objRandom = CreateObject("System.Random") Set objArrList = CreateObject("System.Collections.ArrayList") ArrayList # When scripting in AD, Exchange or even the desktop, I am consistently working with arrays. Adding items and sorting arrays always required custom functions, overly wordy statements or re-dimensioning. This made working with arrays cumbersome. Their example for sorting the non-.net way: