如何以编程方式打开或关闭受密码保护的共享? [英] How do I turn Password Protected Sharing on or off programmatically?
问题描述
Windows Vista 和 7 在网络和共享中心有这个开关.默认情况下它处于打开状态,即使共享与所有人共享(如公共文件夹),也可以防止未经身份验证的访问.我需要教我的应用程序自动打开和关闭它.如何?我怀疑注册表中的某个值对此负责,但我不知道如何找到它.
Windows Vista and 7 has this switch in Network and Sharing Center. It's on by default, and that prevents unauthenticated access to shares even if they're shared with Everyone (like the Public folder). I need to teach my application to turn it on and off automagically. How? I suspect there is a value somewhere in the registry that's responsible for this, but I have no idea how to find it.
推荐答案
可能为时已晚 :) ,但希望对其他人有用.
Probably too late :) , but hopefully useful for others.
以下步骤对我来说效果很好(它也适用于 W8 消费者预览版).
The following steps worked just fine for me (it worked on W8 consumer preview too).
关闭它:
1 - 通过运行启用访客帐户
1 - Enable guest account by running
net user guest/active:yes
net user guest /active:yes
2 - 通过运行获取来宾用户 SID,例如,
2 - Obtain guest user SID by running, for example,
wmic useraccount where name='guest' get sid
wmic useraccount where name='guest' get sid
3 - 获得对注册表文件夹 HKLMSECURITY 的写入权限
3 - Obtain write access to registry folder HKLMSECURITY
4 - 将以下键修改为:
4 - Modify the following key, where $SID is the sid obtained in point 2, to:
[HKEY_LOCAL_MACHINESECURITYPolicyAccounts$SIDActSysAc]
@=hex(0):41,00,00,00
[HKEY_LOCAL_MACHINESECURITYPolicyAccounts$SIDActSysAc]
@=hex(0):41,00,00,00
5 - 重新启动机器(直到现在,我还没有找到更好的方法来使更改生效)
5 - restart the machine (until now, I didn't find a better way to make the change effective)
再次开启:
[HKEY_LOCAL_MACHINESECURITYPolicyAccounts$SIDActSysAc]
@=hex(0):c1,00,00,00
[HKEY_LOCAL_MACHINESECURITYPolicyAccounts$SIDActSysAc]
@=hex(0):c1,00,00,00
然后重启
这篇关于如何以编程方式打开或关闭受密码保护的共享?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!