wangdef09
2017-05-25 13:47:09 +08:00
rem 批处理获取管理员权限
:-------------------------------------
%1 mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&&exit /b
CD /D "%~dp0"
:-------------------------------------
::添加阻止程序出站规则
(
echo "Office_OfficeClickToRun","%ProgramFiles%\Common Files\microsoft shared\ClickToRun\OfficeClickToRun.exe"
echo "Office_msoia","%ProgramFiles%\Microsoft Office\root\Office16\msoia.exe"
echo "Office_WINWORD","%ProgramFiles%\Microsoft Office\root\Office16\WINWORD.EXE"
echo "Office_EXCEL","%ProgramFiles%\Microsoft Office\root\Office16\EXCEL.EXE"
echo "Office_POWERPNT","%ProgramFiles%\Microsoft Office\root\Office16\POWERPNT.EXE"
echo "Office_VISIO","%ProgramFiles%\Microsoft Office\root\Office16\VISIO.EXE"
echo "Office_WINPROJ","%ProgramFiles%\Microsoft Office\root\Office16\WINPROJ.EXE"
echo "Office_MSPUB","%ProgramFiles%\Microsoft Office\root\Office16\MSPUB.EXE"
echo "Office_MSACCESS","%ProgramFiles%\Microsoft Office\root\Office16\MSACCESS.EXE"
echo "AutoCAD_LMU","%ProgramFiles%\Common Files\Autodesk Shared\AdLM\R11\LMU.exe"
echo "AutoCAD_DADispatcherService","C:\Program Files\Autodesk\AutoCAD 2016\DADispatcherService.exe"
echo "AutoCAD_acad","C:\Program Files\Autodesk\AutoCAD 2016\acad.exe"
)>list.txt
FOR /F "usebackq tokens=1,2 delims=," %%i in ( list.txt ) do (
netsh advfirewall firewall del rule name="%%i">nul 2>nul
netsh advfirewall firewall add rule name="%%i" program=%%j action=block dir=out>nul
echo 阻止%%i 程序出站规则已添加
)
del list.txt
::添加阻止服务出站规则
(
echo "Windows Update","wuauserv"
)>list.txt
set svchost_exe="%%systemroot%%\system32\svchost.exe"
FOR /F "usebackq tokens=1,2 delims=," %%i in ( list.txt ) do (
netsh advfirewall firewall del rule name=%%i>nul 2>nul
netsh advfirewall firewall add rule name=%%i service=%%j action=block dir=out program="%svchost_exe%">nul
echo 阻止%%i 服务出站规则已添加
)
del list.txt
pause
rem netsh advfirewall firewall add rule,就会有帮助内容,里面正好有设置端口的例子
rem netsh advfirewall firewall del rule name=%%i>nul 2>nul
rem netsh advfirewall firewall add rule name="%%i" program=%%j action=block dir=out>nul
---------------------------------------------------------------------------------------------------------------------------------------
以上存为批处理,管理员运行