在 Windows 防火墙中打开端口涉及哪些 API 调用?

发布于 2024-07-18 09:23:50 字数 155 浏览 14 评论 0原文

我有一个批处理文件,可以在大约 1 秒内安装 WinVNC 并启动服务。 但是,我仍然需要手动进入 Windows 防火墙并打开端口以允许连接。 我怎样才能以编程方式做到这一点?

如果我可以从批处理文件中执行此操作,那将是理想的,但如果有必要,我可以编写一个 EXE。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

疯到世界奔溃 2024-07-25 09:23:50

Windows 防火墙有自己的 API 用于此目的:Windows 防火墙和具有高级安全性的 Windows 防火墙。 查看 INetFwOpenPorts::Add() 方法。

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

2024-07-25 09:23:50

让我Google 为您提供
http://www.windowsecurity.com/articles/Customizing-Windows-Firewall。 html

此页面包含多种自定义防火墙的方法,其中使用 netsh.exe 似乎可以通过命令行访问 Windows 防火墙。

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.

海拔太高太耀眼 2024-07-25 09:23:50

这是我过去多次使用过的好资源。 我知道这是典型的“指向 RTFM 站点”,但实际上,它是一个很好的资源,而且我已经成功地使用了它。

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

祝你好运。

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.

怀里藏娇 2024-07-25 09:23:50

shoosh 帮我在谷歌上搜索了一下,我想出了这个,效果非常好。

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

将 #### 替换为端口。

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

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

Replacing #### with the port.

笔芯 2024-07-25 09:23:50

查看Windows防火墙的源代码(发布在google groups,Win32上)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文