how can i generate an .exe file trough scripting in unity?

how can i do that? i’m planning to create a application packer(for unity apps only) but i’m facing this problem, so, how can i build a .exe file?

You have to use the BuildPileline, whilst targeting windows.