Variants of 将在外，君命有所不受?
It should be 君令有所不受. The whole sentence 将在外，君令有所不受 means: (if) the general is far away (at the battlefield), he does not have to obey all emperor's orders. The deeper meaning is that the general should judge and act according to the real situations at the battlefield and thus doesn't need to obey all the orders.

将在军 means the same as 将在外. 军 there means at war as well. Hence 将在军 is also correct.

君命 is the same as 君令. Both 命 and 令 mean order/command there. Hence both 君命 and 君令 are correct. 军命 is not correct. It does not have the right meaning.

主令 means one's master's order, 主 means master. So it means the same as well.