Because he's just not that dumb.
I just watched The Avengers: Age of Ultron last night. There were a couple of plot elements that bothered me, especially since I'm a huge computer nerd. But I finally came to a conclusion that allowed me to reconcile these questions. Oh, by the way,