Question

I have a batch file that installs WinVNC in about 1 second and starts up the service. However, I still have to manually go into the Windows Firewall and open a port to allow connections. How can I do that programmatically?

If I could do it from inside the batch file, that would be ideal, but I'm ok writing an EXE if that's necessary.

Was it helpful?

Solution

Let me google that for you:
http://www.windowsecurity.com/articles/Customizing-Windows-Firewall.html

This page includes a multitude of ways to customize the firewall, among those the use of netsh.exe that seem to give command line access to windows firewall.

OTHER TIPS

Windows Firewall has its own API for that purpose: Windows Firewall and Windows Firewall with Advanced Security. Look at the INetFwOpenPorts::Add() method.

Here is a good resource that I have used multiple times in the past. I know it's the typical 'point to the RTFM site', but really, it is a good resource and I have used it successfully.

http://msdn.microsoft.com/en-us/library/aa366415(VS.85).aspx

Good luck.

shoosh googled it for me and I came up with this, which works perfectly.

netsh firewall add portopening tcp #### "VNC"

Replacing #### with the port.

See the source code of Windows firewall (posted on google groups, Win32)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top