In my applications I generally use SQL Instance enumerator to get all the instances of SQL Server. But I've found that running a firewall and/or internet security doesn't allow the application to access the instances. For this, I've to advise the person to turn off the firewall so that it can access the instances which isn't a good idea. I googled but I found some batch file scripts that work for particular Windows version (Windows Server 2008, XP etc).
But I want to know some generic script or method which opens the ports for SQL Server on any machine. How do I resolve the issue?
You'll probably find this link, and this one useful (C# code).
Maybe also some powershell scripts would do the trick: here and here
But it's about Windows Firewall only. Keep in mind there are different software firewalls on the market, and most of the time there also is an hardware firewall (sometimes more than one).