|
本帖最后由 smalldimple 于 2021-9-27 16:49 编辑
我这里有段共享文件夹的代码。看看哪位高手可以改成共享打印机的代码啊!把以下代码做成bat文件,把想共享的文件夹拖进来,回车就行。
@echo off
:lab1
cls
color 2f
echo.
set Choice=
echo 请将您要共享的目录直接拖入本窗口,然后回车:
echo.
echo. 【 注意:共享文件夹名这里预设为:共享目录 】
echo.
set /p Choice=
if ""%Choice%"" == "" goto lab1
echo.
SetLocal EnableDelayedExpansion
net accounts /maxpwage:unlimited
net share "共享目录"=""%Choice%"" /grant:%UserName%,change /users:3 >nul 2>nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Lsa" /f /v "ForceGuest" /t REG_DWORD /d 0 >nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Lsa" /f /v "LimitBlankPasswordUse" /t REG_DWORD /d 0
reg add "HKLM\SYSTEM\ControlSet001\Control\Lsa" /f /v "RestrictAnonymousSAM" /t REG_DWORD /d 1
reg add "HKLM\SYSTEM\ControlSet001\Control\Lsa" /f /v "RestrictAnonymous" /t REG_DWORD /d 1 >nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Lsa" /f /v "EveryoneIncludesAnonymous" /t REG_DWORD /d 0
reg add "HKLM\SYSTEM\ControlSet001\Control\Lsa\MSV1_0" /f /v "NtlmMinClientSec" /t REG_DWORD /d 0 >nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Lsa\MSV1_0" /f /v "NtlmMinServerSec" /t REG_DWORD /d 0 >nul
reg add "HKLM\SYSTEM\ControlSet001\Control\Lsa\MSV1_0" /f /v "RestrictReceivingNTLMTraffic" /t REG_DWORD /d 1
reg add "HKLM\SYSTEM\ControlSet001\Services\NetBT\Parameters" /f /v "TransportBindName" /t REG_SZ /d \Device\
reg add "HKLM\SYSTEM\ControlSet001\Services\NetBT\Parameters" /f /v "UseNewSmb" /t REG_DWORD /d 1 >nul
reg add "HKLM\SYSTEM\ControlSet001\Services\LanmanServer\Parameters" /f /v "RestrictNullSessAccess" /t REG_DWORD /d 1 >nul
reg add "HKLM\SYSTEM\ControlSet001\Services\LanmanServer\Parameters" /f /v "AutoShareServer" /t REG_DWORD /d 0 >nul
reg add "HKLM\SYSTEM\ControlSet001\Services\LanmanServer\Parameters" /f /v "AutoShareWks" /t REG_DWORD /d 0 >nul
reg delete "HKLM\SYSTEM\ControlSet001\Services\LanmanServer\Parameters" /f /v "NullSessionPipes" >nul 2>nul
reg delete "HKLM\SYSTEM\ControlSet001\Services\LanmanServer\Parameters" /f /v "SMB1" >nul 2>nul
reg delete "HKLM\SYSTEM\ControlSet001\Services\LanmanServer\Parameters" /f /v "SMB2" >nul 2>nul
reg delete "HKLM\SYSTEM\ControlSet001\Services\NetBT\Parameters" /f /v "SMBDeviceEnabled" >nul 2>nul
for /f %%a in ('reg query "HKLM\SYSTEM\ControlSet001\Services\NetBT\Parameters\Interfaces" /k /f "Tcpip_" 2^>nul') do (reg add "%%~a" /f /v "NetbiosOptions" /t REG_DWORD /d 0)
for %%a in (Browser DHCP fdPHost lmhosts LanmanServer LanmanWorkstation NetBT SharedAccess SSDPSRV) do (
sc config "%%~a" start=auto >nul
net start "%%~a" >nul 2>nul
)
pause
echo.goto lab1 |
|