如何以编程方式打开或关闭密码保护共享? [英] How do I turn Password Protected Sharing on or off programmatically?

查看:32
本文介绍了如何以编程方式打开或关闭密码保护共享?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 - 通过运行

net 用户来宾/active:yes

net user guest /active:yes

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

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

wmic useraccount where name='guest' 获取 sid

wmic useraccount where name='guest' get sid

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

3 - Obtain write access to registry folder HKLM\SECURITY

4 - 修改以下键,其中 $SID 是第 2 点获得的 sid,为:

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

[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\$SID\ActSysAc]
@=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_MACHINE\SECURITY\Policy\Accounts\$SID\ActSysAc]
@=hex(0):c1,00,00,00

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

然后重启

这篇关于如何以编程方式打开或关闭密码保护共享?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆