Export structure and data without a wizard Using Sql Server 2008 R2 (but I could possibly upgrade if required).

I want to generate scripts for the database structure as well as the data for a schema. 

The Generate Scripts wizard does what I want but I need to be able to automate it (so needs to be called from T-SQL or alternatively external program).

How can I do this?
I know that Red Gate SQL compare has a command line interface so you could write and schedule a batch file to generate the scripts. Details here
You could then use SQLcmd to execute the scripts.