Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you programmatically Turn Password Protected Sharing on/off in Windows 7?

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.

like image 875
mFontenot Avatar asked Nov 04 '22 23:11

mFontenot


1 Answers

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

like image 187
XP1 Avatar answered Nov 12 '22 12:11

XP1