Monday, May 29, 2006

Virtual Router for Virtual Server 2005 R2...

FreeSCO it seems does not support Virtual Server 2005... version 0.3.5 won't even boot and the developers don't seem to care. Funny thing is that even though Virtual Server uses one of the most compatible NIC chipsets around, the DEC-based Intel 21140, the drivers available for FreeSCO just won't work.

After trying to get it working for an hour or so (I've previously used FreeSCO on VMWare, and it just works straight out of the box), I gave up and started looking for another small linux based router, and found Coyote Linux.

Even though the floppy version is no longer being maintained, it does everything you want and more. They even have a wizard based image creator for Windows - very nice indeed. When you're going through the Wizard, ensure that you select the 'tulip' NIC type for both interfaces. And, just like FreeSCO on VMWare, it works straight out of the box with 16Mb of RAM and no VHD.

Here is a brief how to:

1) Create a new virtual machine with 16MB RAM, no hard disk, no CD/DVD, no SCSI adapter and 2 NICs.
2) Set the floppy drive to always use the image you got from the Coyote wizard
3) Coyote should now start up without a hitch.
4) Add the following line to the firewall configuration file: access Y permit all int-net lan-net all
This will allow all traffic to simply route between the 2 networks.
5) You're done.

Obviously Coyote has been designed to function as much more than a simple router, and some of the other features will no doubt come in handy to simulate DMZ or QoS conditions you get in the real world.

So go and grab it from here, and thanks very much to the good ppl who made it. Give them some business if you can!

Coyote Linux Router

Monday, May 15, 2006

Adding Console fonts...

I recently switched to using the newish Consolas font from Microsoft for VS2005 / text editors. It's a nice font, and I was wondering how I could get it into the console if it was even possible. Turns out it is, with this 'unsupported' hack from Microsoft

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont]

KB article is here.

Saturday, May 13, 2006

Goodbye Array... hello Disconnected DataSet!

I've always hated working with Arrays in VBScript... they're fiddly at the best of times. And if you ever have to sort the data in an array (let alone a multidimensional one), you're pretty much screwed. Enter the Disconnected DataSet.

Instead of building an array and stuffing data into it, you can create an in memory database using ADO that only exists while the script executes. I'm sure from an application perspective there are tons of risks associated with using such a technique to actually talk back to real database at some point, but for administrative scripting, it's a godsend.

So say you wanted to query all the services on a machine using WMI, and list them in order of the state they were in as opposed to the alphabetical order of the service name (which is the order WMI would return the query in). You would simply:

Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "ServiceName", adVarChar, MaxCharacters
DataList.Fields.Append "ServiceState", adVarChar, MaxCharacters
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer& "\root\cimv2")
Set colServices = objWMIService.ExecQuery _
("SELECT * FROM Win32_Service")
For Each Service in colServices
DataList("ServiceName") = Service.Name
DataList("ServiceState") = Service.State
DataList.Sort = "ServiceState"
Do Until DataList.EOF
Wscript.Echo DataList.Fields.Item("ServiceName") _
& vbTab & DataList.Fields.Item("ServiceState")

Here is the link to where that code came from... I am sure I will be using this technique a lot from now on.