WannaCry was built around a vulnerability in the SMB protocol. The best way to prevent or at least minimize the impact of ransomware like WannaCry is to keep all systems up to date with patches. Employees can also be trained on following security best practices, such as ways to recognize email-based phishing attacks.
Computer security agencies, such as the United States CISA, recommend implementing an Active Defense system to protect a network against advanced threats like ransomware. A Deception Technology solution like Acalvio ShadowPlex is at the core of an Active Defense system for securing a network.