To use mental ray baking (to texture) to save a lightmap from the command line
For example:
Render -r lightmap -rd "C:/output" -sel pSphere1 -sel pSphere2 -override 1 -colorMode 3 -occlusionRays 16
The above command bakes both pSphere1 and pSphere2 and saves lightmaps in C:/output.
By default, the texture bake set assigned to each object is used to render the lightmap. In the command above, the bake occlusion is set to 16 occlusion rays. The default values are used for any unspecified texture bake set attributes.
See Generating lightmaps using the command line for more information.