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

后端 未结 6 678
梦毁少年i
梦毁少年i 2020-12-29 16:24

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 Every

6条回答
  •  一生所求
    2020-12-29 16:49

    Take a look at this file (disable_password_protected_sharing.bat)

    @echo off
    echo 12- get sid gust variable
    for /f "delims= " %%a in ('"wmic useraccount where name='guest' get sid"') do (
           if not "%%a"=="SID" (          
              set sid_guest=%%a
              goto :loop_end
           )   
        )
    
    :loop_end
    
    echo 13- create script for regini
    @echo \Registry\Machine\SECURITY [1 5 7 11 17 21]> x
    @echo \Registry\Machine\SECURITY\policy [1 5 7 11 17 21]>> x
    @echo \Registry\Machine\SECURITY\policy\accounts [1 5 7 11 17 21]>> x
    @echo \Registry\Machine\SECURITY\policy\accounts\%sid_guest% [1 5 7 11 17 21]>> x
    @echo \Registry\Machine\SECURITY\policy\accounts\%sid_guest%\ActSysAc [1 5 7 11 17 21]>> x
    
    echo 14- add permission for machine/security
    net user guest /active:yes
    regini x
    del x
    @echo Windows Registry Editor Version 5.00 > y.reg
    @echo [HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\%sid_guest%\ActSysAc] >> y.reg
    @echo @=hex(0):41,00,00,00 >> y.reg
    reg import y.reg
    del y.reg
    
    echo Windows will now reboot.
    Pause
    
    shutdown -r
    

    it works fine in windows7

提交回复
热议问题