Use the following syntax:
devenv.exe {Solution Name} /command {Macro name}
Example:
devenv.exe "myproject.sln" /command "Macros.Syncfusion.Utils.FormatProjectAndClose"
Visual Studio will start up, load the solution, run the macro and then terminate. Be sure to check that devenv.exe is available from your command line. Normally, you just have to run VSVARS32.bat to ensure this if you do not already have this in your path.
Contributed from George Shepherd's Windows Forms FAQ