为非管理员用户帐户中运行的进程创建防火墙规则
我有一个基本要求 - 通过在出现提示时创建防火墙规则(打开 Windows 防火墙)来在 Windows 上顺利运行我的应用程序。
当我第一次运行应用程序时以具有管理员权限的用户身份登录系统时,防火墙会出现提示,我通知它允许我的应用程序并创建规则,很好。
但是,当我打开电脑、以非管理员用户身份登录并运行应用程序时,防火墙会按预期显示提示;然而,当我单击与管理员用户相同的选项时,防火墙提示不断弹出,即使我每次出现提示时都单击“允许/确定”。仅当我单击“取消/阻止”应用程序运行时,提示才会消失,这显然不是我想要做的。
所以这里出现了百万美元的问题,我应该在第一次单击防火墙提示以允许我的应用程序时成功创建防火墙规则来更改我的应用程序代码以顺利运行;与我以具有管理员权限的用户身份运行应用程序时的工作方式完全相同。
我已经在网上进行了一些搜索,并了解到非管理员用户无法修改防火墙规则(甚至无法创建它们???)。顺便说一句,我已经在 Windows XP、Vista 7 x86 和 x64 上测试了这种情况,结果相同。
如果有人遇到和/或解决了类似的问题,请分享您的知识。如果我遗漏了什么,请让我明白我遗漏了什么。
谢谢
I have a basic requirement - to run my application smoothly on Windows by creating firewall rules when prompted, that has windows firewall turned-ON.
When I log in to my system as an user with Admin privileges when I run my application the first time, the firewall comes up with a prompt, I inform it to allow my app and create a rule, nice.
However when I turn-on my PC, log in as a non-Admin user, and I run my application, the firewall shows up with a prompt as expected; however when I click on the same options as I did from the Admin user, the firewall prompt keeps popping up continuously even though I clicked on Allow /ok every time the prompt appears. The prompt only goes away when I click on "Cancel / Block" the application from running, which is obviously not what I want to do.
So here comes the million $ question, What and How should I change my application code to run smoothly by creating the firewall rule successfully the first time I click on the firewall prompt to allow my application; exactly the same way it is working when I run my application as an user with Admin privileges.
I have done my bit of searching online and have come to understand that Non-admin users cannot modify firewall rules (cannot even create them???). BTW I have tested this scenario on Windows XP, Vista 7 both x86 and x64 with same results.
If someone has encountered and / or solved similar issues please share your knowledge. If I am missing something, please make me understand what I am missing.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您所尝试的操作在
非管理员
帐户中是不可能的。您可以尝试通过创建新进程来使用 Windowsrunas
功能来获得admin
权限,以便提示用户输入用户名
> 和管理员帐户的密码,这将为您的程序提供为您的程序创建防火墙规则所需的访问权限。您还可以查看 CreateProcessAsUser 或 LogOnUSer 。基本上,为了成功完成您想要做的事情,您需要一个代表管理员帐户或具有管理员权限的帐户的令牌。
I don't think what you are trying is possible in a
non-admin
account. What you may try is to gainadmin
privilege by using the windowsrunas
feature by creating a new process, so that the user is prompted for theusername
andpassword
of the Admin Account, which would give your program the required access to create firewall rules for your program.You may also take a look into CreateProcessAsUser or LogOnUSer . Basically in order to succeed in what you are trying to do, you need a token that represents the Administrator account or an account which has admin privileges.