Sometimes the Network Discovery option (under "Control Panel" -> "Network and Internet" -> "Network and Sharing Center" -> "Change advanced sharing options") can't be turned on (actually, it can't stay turned on), for example on the Windows Server 2012 R2.
The reason for this behavior is the fact that certain services are not running.
To enable them go to "Services" Management Console by:
- opening the Task Manager, clicking on "More Details", going to the "Services" tab, then selecting any service, right-clicking on it and selecting the "Open Services" option OR;
- doing as above and selecting the same option from the lower left corner of the "Services" tab OR;
- simply using the services.msc command.
Then enable (by right-clicking the respective service, selecting the "Properties" menu item and selecting "Automatic" in the middle of the "General" tab) and start the following services:
- DNS Client
- Function Discovery Resource Publication
- SSDP Discovery
- UPnP Device Host
In the end just enable the Network Discovery option again (this time it should stay on).