Using windows powershell you can generate scripts for a database and its objects
http://www.mssqltips.com/tip.asp?tip=1842&home
here is a snippet from the article
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
$s = new-object ('Microsoft.SqlServer.Management.Smo.Server') "LOCALHOST\SQL2005_1"
$dbs=$s.Databases
$dbs["Northwind"].Script()