0

I've been looking for a way to accomplish this for several weeks now; this is essentially the same question that was posted here on Stack Overflow almost two years ago, but the answer there doesn't work and I feel that this question is more applicable to super user (which itself has no questions on how to accomplish this specifically from command-line that I could find). None of the suggestions on MSDN or on technet were useful, and I could not find a command with netsh.

My deployment script has a block that looks like this:

echo Updating service settings...
sc config fdPHost start= auto >nul
sc start fdPHost >nul
sc config FDResPub start= auto >nul
sc start FDResPub >nul
sc config SSDPSRV start= auto >nul
sc start SSDPSRV >nul
sc config upnphost start= auto >nul
sc start upnphost >nul
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes >nul
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa /v everyoneincludesanonymous /t REG_DWORD /d 1 /f >nul
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /v restrictnullsessaccess /t REG_DWORD /d 0 /f >nul
net user guest ""

and elsewhere a block like this:

net share ExampleFolder="C:\ExampleFolder" /grant:Everyone,Read >nul
net share Desktop="%USERPROFILE%\Desktop" /grant:Everyone,Read >nul
icacls "C:\ExampleFolder" /grant Everyone:(OI)(CI)R /T /Q >nul
icacls "%USERPROFILE%\Desktop" /grant Everyone:(OI)(CI)R /T /Q >nul

The end goal is for all of the devices on this network to be able to see each other, and for a user with no password to be able to copy to/modify files on all of the other computers' Desktops and ExampleFolders. The only thing I need to happen that these blocks don't accomplish is the toggling of the Password Protected Sharing option located here:
Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings

Password Protected Pain in the...

While it's too late to implement any potential good/working answer into my deployment package, I'm curious enough now to open a Question and potentially give it a bounty (when the option is available). As the tags imply - I'm looking for a pure command-line (cmd.exe) method of accomplishing this on Windows 10, which at some point will probably be added to a batch file. This deployment is on a mid-sized, air-gapped LAN - so please don't feel too bad about what the above settings mean from a security standpoint.

1

This feature depends on a local Guest account:

NET USER Guest /ACTIVE:YES

Is usually enough to make it work.

There is another registry parameter, that needs to be changed, if password protected sharing wasn't disabled before:

[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\{GUEST_USER_SID}\ActSysAc]
@=hex(0):41,00,00,00

disables password protected sharing

[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\{GUEST_USER_SID}\ActSysAc]
@=hex(0):c1,00,00,00

enables it again

SID can be found with WMIC:

WMIC USERACCOUNT WHERE "NAME='Guest'" GET SID
  • Reading about the Guest account manipulation is what resulted in me including the net user guest "" line in my block - though I have tried multiple different things with the guest account. Your suggested answer is not toggling the password protected sharing - neither by itself nor in conjunction with anything else I have. Did you test this first? If yes, what environment are you in that this worked? – mael' Jul 19 at 19:08
  • Well, it sure toggles this option for me, just tested. But I didn't make all other OS modifications you specified. Maybe they broke something for you? – Dm1 Jul 19 at 19:51
  • nah I imaged a fresh Windows 10 Pro laptop and then ran your proposed answer by itself - when that didn’t toggle it I included your answer with my block; still no change. are you using Windows 10? if so what version? – mael' Jul 19 at 20:06
  • This works for me on Windows 10 Pro 1903. – Dm1 Jul 19 at 20:30
  • Just re-imaged another laptop - all I did was update it to 1903 and then run the line you gave - no dice; not even after restart. what is your network type set to when you run it? Private/Public/Home? – mael' Jul 22 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.