If you want to do this via script, you please have to use the AOTClassesGenerator.GenerateAOTClasses and AOTClassesGenerator.GenerateLinkXML methods respectively.
Both methods take a string path for where to store the generated file. This has to be a full file path with the file extension. Thus for the AOTClasses it needs to “*anything*.cs” and for the link.xml it has to be, well, “link.xml” 🙂
Both methods also take a Type[] targetTypes for a collection of types to generate the file for. For the types, you can simply use TypePrefs.GetPreferredTypesList().ToArray() to use the types added in the Preferred Types Editor.