It's basically the VBScript code found there:
… but translated to JScript. I hoped I would have been able to use the XCountChars and YCountChars members of the Win32_ProcessStartup class to run the CMD process with the window size already adjusted. That didn't work though. I had to use the MODE command wich makes it look rather clumsy with all the escaping of special characters.
Anyway, glad it helped.
Discussion forum for all Windows batch related topics.