This represents the basic access method to the DMO object model.
Connect -> Access Object Model -> Disconnect

CREATE procedure dmoScriptServer
  @serverName varchar(30) ,
  @outputPath varchar(255) ,
  @style bit = 0
declare @dmoServer int

-- Check for trailing slash on backup location param
if (substring(@outputPath, len(@outputPath), 1) <> '\') 
    set @outputPath = @outputPath + '\'

/* connect to the server where database to be scripted lives */
exec dmoConnectServer @serverName, @dmoServer OUT

if @dmoServer > 0
    exec dmoScriptServerCollection @serverName, @dmoServer, 'Logins',@outputPath, @style
    exec dmoScriptServerCollection @serverName, @dmoServer, 'Jobserver.Jobs',@outputPath, @style

/* the DMO database scripter is broken. Does not produce useable scripts and may blow up in some situations. 
  An alternate database scripter uses a non dmo routine to script each individual database 
  and it is called from inside the database via dmoScriptDatabase*/    
--    exec dmoScriptServerCollection @serverName, @dmoServer, 'Databases',@outputPath, @style

    exec dmoDisconnectServer @dmoServer