When installing SharePoint 2013, if the server is online, then we regualarly use the (prerequisiteinstaller) to download and configure the prerequisites, but sometimes it will not work for you, due to many reasons, may be the Windows Server version or any other.
One of the common problems is the error of (The tool was unable to install application server role, web server (IIS) role),
After trying many solutions I have found a funny one J
When tracing the log file of the error I found the prerequisiteinstaller.exe is trying to access an exe file within C:\windows\system32, the file name was ( ServerManagerCMD.exe), while the actual name within the same folder was (ServerManager.exe), the solution is very simple, copy that file (ServerManager.exe), and paste it to desktop or wherever, then rename it to be (ServerManagerCMD.exe), yet you can copy it and paste it to the path referred in the log file (C:\windows\system32), don’t worry the old one still function, then go to your prerequisiteinstaller.exe file and you will notice it will work like magic with you :
Don’t worry if the ServerManager console open with you, you can close it and continue working no problem.