Scripts Stored Procedures and Functions through query
This query will script the Procedures and Functions
All you have to do is replace DBname by the actual Database Name
exec master..xp_cmdshell
'bcp "Select routine_definition from DBname.information_Schema.routines order by routine_name" queryout "C:\scripts.sql" -c'
After it runs successfully, the file C:\scripts.sql will have the scripts