如何在 Windows 7 中以编程方式打开/关闭密码保护共享?

发布于 2024-11-02 19:28:00 字数 451 浏览 8 评论 0原文

让我提前道歉。我已经在这里看到这个问题了,但还没有完全回答。 (如何打开或关闭密码保护共享以编程方式关闭?)。我不知道如何在不提出新问题的情况下再次解决问题。如果我应该做一些不同的事情,请告诉我,这样我就不会犯两次同样的错误。

我们使用 C# 编辑网络设置,并向 Windows 7 添加 2 条防火墙规则,以用于需要 Windows XP 样式共享的旧应用程序。除了如何“关闭密码保护共享”之外,我们已经弄清楚了一切。如果有人解决了这个问题,请告诉我。

我已经导出了调整设置之前和之后的整个注册表。使用Beyond Compare来定位任何差异,但没有发现任何有用的东西。任何和所有的想法都会受到赞赏。

Let me apologize ahead of time. I saw this question on here already, but it has not been answered completely. (How do I turn Password Protected Sharing on or off programmatically?). I couldn't figure out how to have a question addressed again, without simply asking a new question. If I should have done something different please let me know so I don't make the same mistake twice.

We are using C# to edit network settings and add 2 firewall rules to Windows 7 for a legacy application that needs Windows XP style shares. We have figured out everything except how to "Turn Off Password Protected Sharing". If anyone has figured this out please let me know.

I have already exported the entire registry before and after adjusting the setting. Used Beyond Compare to locate any difference, but nothing useful was found. Any and all ideas are appreciated.

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

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

发布评论

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

评论(1

岁月如刀 2024-11-09 19:28:00

保罗在这里的回答:
如何开启密码保护以编程方式共享或关闭?


可能为时已晚:),但希望对其他人有用。

以下步骤对我来说效果很好(它也适用于 W8 消费者预览版)。

将其关闭:

1 - 通过运行启用来宾帐户

网络用户访客/活动:是

2 - 通过运行获取来宾用户 SID,例如,

wmic useraccount 其中 name='guest' 获取 sid

3 - 获得对注册表文件夹 HKLM\SECURITY 的写入权限

4 - 修改以下项(其中 $SID 是第 2 点中获取的 sid):

[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\$SID\ActSysAc]
@=hex(0):41,00,00,00

5 - 重新启动机器(到目前为止,我没有找到更好的方法使更改生效)

以再次打开它:

[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\$SID\ActSysAc]
@=hex(0):c1,00,00,00

然后重新启动

paolo's answer from here:
How do I turn Password Protected Sharing on or off programmatically?


Probably too late :) , but hopefully useful for others.

The following steps worked just fine for me (it worked on W8 consumer preview too).

to turn it off:

1 - Enable guest account by running

net user guest /active:yes

2 - Obtain guest user SID by running, for example,

wmic useraccount where name='guest' get sid

3 - Obtain write access to registry folder HKLM\SECURITY

4 - Modify the following key, where $SID is the sid obtained in point 2, to:

[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\$SID\ActSysAc]
@=hex(0):41,00,00,00

5 - restart the machine (until now, I didn't find a better way to make the change effective)

to turn it on again:

[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\$SID\ActSysAc]
@=hex(0):c1,00,00,00

then restart

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