一键开启局域网共享源码

最近好多人同时向我问这个问题,其实局域网共享设置并不难,仅仅几个步骤,但是网上的教程大多复杂化了,搞得很多人不敢尝试,自己参考网络上的资料,编写了一个批处理脚本,可以实现一键开启局域网共享,现在分享出来。


新建一个空白文档,把下面代码复制粘贴进去,保存后,修改下文档的文件名(注意后缀必须改为.bat),之后打开即可运行。

@ECHO OFF
title 一键开启局域网共享  by 凣高先生
color 2F
cls
echo.
echo.
echo.  1.开启匿名访问 
echo.  2.启用验证访问(需要输入用户名密码) 
echo.  3.关闭共享 
echo.  4.返回
echo.
echo.
set choice=
set /p choice= ● 请选择‖
if /i "%choice%"=="1" goto share1
if /i "%choice%"=="2" goto share2
if /i "%choice%"=="3" goto share3
if /i "%choice%"=="4" goto end
goto share
:share1
cls
net user Guest /active:yes
echo Windows Registry Editor Version 5.00 >share.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Lsa] >>share.reg
echo "restrictanonymous"=dword:00000000 >>share.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>share.reg
echo "restrictanonymous"=dword:00000000 >>share.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>share.reg
echo "limitblankpassworduse"=dword:00000000 >>share.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Lsa] >>share.reg
echo "limitblankpassworduse"=dword:00000000 >>share.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>share.reg
echo "forceguest"=dword:00000001 >>share.reg
echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count] >>share.reg
echo "HRZR_EHAPCY"=hex:0C,00,00,00,26,00,00,00,F0,FB,E5,52,64,95,C6,01 >>share.reg
echo "HRZR_EHAPCY:"P:\JVAQBJF\flfgrz32\sverjnyy.pcy",Jvaqbjf 防火墙"=hex:0C,00,00,00,08,00,00,00,F0,FB,E5,52,64,95,C6,01 >>share.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List] >>share.reg
echo "445:TCP"="445:TCP:LocalSubNet:Enabled:@xpsp2res.dll,-22005" >>share.reg
echo "137:UDP"="137:UDP:LocalSubNet:Enabled:@xpsp2res.dll,-22001" >>share.reg
echo "138:UDP"="138:UDP:LocalSubNet:Enabled:@xpsp2res.dll,-22002" >>share.reg
echo "139:TCP"="139:TCP:LocalSubNet:Enabled:@xpsp2res.dll,-22004" >>share.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Epoch] >>share.reg
echo "Epoch"=dword:000001ED >>share.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Providers] >>share.reg
echo "LogonTime"=hex:E8,31,8E,4F,64,95,C6,01 >>share.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List] >>share.reg
echo "445:TCP"="445:TCP:LocalSubNet:Enabled:@xpsp2res.dll,-22005" >>share.reg
echo "137:UDP"="137:UDP:LocalSubNet:Enabled:@xpsp2res.dll,-22001" >>share.reg
echo "138:UDP"="138:UDP:LocalSubNet:Enabled:@xpsp2res.dll,-22002" >>share.reg
echo "139:TCP"="139:TCP:LocalSubNet:Enabled:@xpsp2res.dll,-22004" >>share.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Epoch] >>share.reg
echo "Epoch"=dword:000001ED >>share.reg
regedit /s share.reg
del share.reg
echo.
echo.
echo √. 局域网匿名访问已开启ゞ
echo 注意:本机要重启后才会生效。
echo ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
echo.
pause & goto logon
:end
goto logon
:share2
cls
net user Guest /active:no
echo Windows Registry Editor Version 5.00 >usershare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Lsa] >>usershare.reg
echo "restrictanonymous"=dword:00000000 >>usershare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>usershare.reg
echo "restrictanonymous"=dword:00000000 >>usershare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>usershare.reg
echo "limitblankpassworduse"=dword:00000000 >>usershare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Lsa] >>usershare.reg
echo "limitblankpassworduse"=dword:00000000 >>usershare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>usershare.reg
echo "forceguest"=dword:00000000 >>usershare.reg
echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count] >>usershare.reg
echo "HRZR_EHAPCY"=hex:0C,00,00,00,26,00,00,00,F0,FB,E5,52,64,95,C6,01 >>usershare.reg
echo "HRZR_EHAPCY:"P:\JVAQBJF\flfgrz32\sverjnyy.pcy",Jvaqbjf 防火墙"=hex:0C,00,00,00,08,00,00,00,F0,FB,E5,52,64,95,C6,01 >>usershare.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List] >>usershare.reg
echo "445:TCP"="445:TCP:LocalSubNet:Enabled:@xpsp2res.dll,-22005" >>usershare.reg
echo "137:UDP"="137:UDP:LocalSubNet:Enabled:@xpsp2res.dll,-22001" >>usershare.reg
echo "138:UDP"="138:UDP:LocalSubNet:Enabled:@xpsp2res.dll,-22002" >>usershare.reg
echo "139:TCP"="139:TCP:LocalSubNet:Enabled:@xpsp2res.dll,-22004" >>usershare.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Epoch] >>usershare.reg
echo "Epoch"=dword:000001ED >>usershare.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Providers] >>usershare.reg
echo "LogonTime"=hex:E8,31,8E,4F,64,95,C6,01 >>usershare.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List] >>usershare.reg
echo "445:TCP"="445:TCP:LocalSubNet:Enabled:@xpsp2res.dll,-22005" >>usershare.reg
echo "137:UDP"="137:UDP:LocalSubNet:Enabled:@xpsp2res.dll,-22001" >>usershare.reg
echo "138:UDP"="138:UDP:LocalSubNet:Enabled:@xpsp2res.dll,-22002" >>usershare.reg
echo "139:TCP"="139:TCP:LocalSubNet:Enabled:@xpsp2res.dll,-22004" >>usershare.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Epoch] >>usershare.reg
echo "Epoch"=dword:000001ED >>usershare.reg
regedit /s usershare.reg
del usershare.reg
echo.
echo.
echo √. 局域网验证访问已开启ゞ
echo 友情提示:无需重启,其它机现在就可以访问本机了。
echo ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
echo.
pause & goto logon
:end
goto logon
:share3
cls
net user Guest /active:no
echo Windows Registry Editor Version 5.00 >offshare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Lsa] >>offshare.reg
echo "restrictanonymous"=dword:00000001 >>offshare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>offshare.reg
echo "restrictanonymous"=dword:00000001 >>offshare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>offshare.reg
echo "limitblankpassworduse"=dword:00000001 >>offshare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Lsa] >>offshare.reg
echo "limitblankpassworduse"=dword:00000001 >>offshare.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa] >>offshare.reg
echo "forceguest"=dword:00000001 >>offshare.reg
echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{75048700-EF1F-11D0-9888-006097DEACF9}\Count] >>offshare.reg
echo "HRZR_EHAPCY"=hex:0C,00,00,00,2A,00,00,00,90,AF,A4,87,A4,95,C6,01 >>offshare.reg
echo "HRZR_EHAPCY:"P:\JVAQBJF\flfgrz32\sverjnyy.pcy",Jvaqbjf 防火墙"=hex:0C,00,00,00,13,00,00,00,90,AF,A4,87,A4,95,C6,01 >>offshare.reg echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\RNG] >>offshare.reg
echo "Seed"=hex:AC,6F,9A,2B,11,64,44,68,EC,90,1B,76,72,A7,0A,14,4C,79,37,BB,FD,BD,70,B2,B2,58,D5,B5,89,5C,B6,4E,3B,18,A5,26,46,BC,3E,6A,30,A4,7D,A0,56,E6,6A,B5,57,3A,BF,A1,CD,CA,B6,64,4C,F9,0E,D2,64,ED,86,1F,61,F6,D1,01,0B,7C,8D,BD,73,10,C8,4E,57,93,4E,90 >>offshare.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List] >>offshare.reg
echo "445:TCP"="445:TCP:LocalSubNet:Disabled:@xpsp2res.dll,-22005" >>offshare.reg
echo "137:UDP"="137:UDP:LocalSubNet:Disabled:@xpsp2res.dll,-22001" >>offshare.reg
echo "138:UDP"="138:UDP:LocalSubNet:Disabled:@xpsp2res.dll,-22002" >>offshare.reg
echo "139:TCP"="139:TCP:LocalSubNet:Disabled:@xpsp2res.dll,-22004" >>offshare.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Epoch] >>offshare.reg
echo "Epoch"=dword:000001FC >>offshare.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List] >>offshare.reg
echo "445:TCP"="445:TCP:LocalSubNet:Disabled:@xpsp2res.dll,-22005" >>offshare.reg
echo "137:UDP"="137:UDP:LocalSubNet:Disabled:@xpsp2res.dll,-22001" >>offshare.reg
echo "138:UDP"="138:UDP:LocalSubNet:Disabled:@xpsp2res.dll,-22002" >>offshare.reg
echo "139:TCP"="139:TCP:LocalSubNet:Disabled:@xpsp2res.dll,-22004" >>offshare.reg echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Epoch] >>offshare.reg
echo "Epoch"=dword:000001FC >>offshare.reg
regedit /s offshare.reg
del offshare.reg
echo.
echo.
echo √. 已关闭局域网共享ゞ
echo 友情提示:不必重启,设置已生效。
echo ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
echo.
pause & goto logon



正文到此结束

随便看看

发表评论

    avatar
    微笑 大笑 拽 大哭 奸笑 流汗 喷血 生气 囧 不爽 晕 示爱 卖萌 吃惊 迷离 爱你 吓死了 呵呵