Military dictators appoint the electoral commission, and the electoral commission decides who can run.
http://english.ahram.org.eg/NewsContent/36/122/39510/Presidential-elections-/Presidential-elections-news/Electoral-commission-upholds-ban-on--presidential-.aspx