Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I turn Password Protected Sharing on or off programmatically?

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.

like image 266
CannibalSmith Avatar asked Nov 05 '09 19:11

CannibalSmith


People also ask

How do I turn off password protected sharing?

Go to the Start menu search bar, type in 'control panel,' and select the best match. Select Network and Internet -> Network and Sharing Center. From the left-hand panel, click on Change advanced sharing settings. Expand All Networks tab, select the Turn off password protected sharing and click on Save changes.

How do I turn on password protected sharing?

Click on Change advanced sharing settings. Scroll down and expand All Networks. Scroll down to Password protected sharing. Click on Turn on password protected sharing or Turn off password protected sharing .

How do I turn off password protected sharing in Windows 11?

Click on the Users entry on the right. Next, right-click on Guest and select Properties from the context menu. Now, tick the checkbox for Password never expires and untick the others, and click on OK to save the changes. Restart the computer and password protected sharing will be turned off in Windows 11.


2 Answers

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

like image 151
paolo Avatar answered Sep 28 '22 05:09

paolo


Export the complete register as 1.reg, turn sharing on (or off, if it was on), export to 2.reg and check for the differences?

To be able to use the diff utility, export the files in Win9X/NT4 registration files (*.reg) -format

like image 29
Kimvais Avatar answered Sep 28 '22 05:09

Kimvais