One thing I noticed (from May 5, 2013 code under patches) is that it runs fine from a cmd prompt, but when scheduled as a sql sever agent job runnings under cmdexec, it errors out with:
Exception caught in Main()
--The handle is invalid.
-- at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
at System.Console.SetWindowSize(Int32 width, Int32 height)
at ScriptDb.Program.Main(String args) in C:\Users\Darren\Documents\Visual Studio Projects\ScriptDB\Program.cs:line 57
I had to comment out the lines:
//Console.BufferHeight = 2000;
//Console.BufferWidth = 500;
And rebuild it, then it worked fine. This was on a Windows 2008 R2 server, and SQL Server 2008 R2.