Revealing the relationship between electronic structures and the decomposition mechanism is the key to explore novel primary explosives. A systematic investigation on electronic structures and microscopic decomposition pathways of 4-amino-5-mercapto-1,2,4-triazole (AMTA) and 4-amino-5-mercapto-3-nitro-1,2,4- triazole (AMNTA) in the ground, charged, and excited states (S0→T1) has been analyzed with density functional theory (DFT). The effect of electrifying molecules and exciting electrons on the decomposition mechanism has been clarified by thermodynamics and kinetics. This study shows that the neutral amino dissociation from the triazole ring has an advantage among different substituents dissociation. For AMTA, electrifying the molecule can make the ring cleavage occur easily at the "N4-C5" site, and exciting electrons makes the triazole ring decompose directly and release 3.3 kcal/mol of heat. For AMNTA, positively electrifying the molecule makes CONO isomerization become the dominant reaction and hinders the H-transfer reaction. When the molecule is electrified negatively or its electrons are excited, H-transfer will take place preferentially. This work sheds light on how to control the decomposition pathways of novel primary explosives at the electronic structure level by the means of electrifying molecules and exciting electrons.